Skip to content

Commit 88d40dc

Browse files
authored
Rollup merge of rust-lang#40689 - GuillaumeGomez:rustdoc-associated-type-formatting, r=frewsxcv
Add whitespace around "=" in assoc items Part of rust-lang#40641. r? @rust-lang/docs Before: <img width="1440" alt="screen shot 2017-03-20 at 22 42 34" src="https://cloud.githubusercontent.com/assets/3050060/24123102/89181d8c-0dbe-11e7-897c-841497cf7001.png"> After: <img width="1440" alt="screen shot 2017-03-20 at 22 42 36" src="https://cloud.githubusercontent.com/assets/3050060/24123118/8dec176e-0dbe-11e7-9759-cabbd062a4c2.png">
2 parents 5947db1 + f531722 commit 88d40dc

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

src/librustdoc/html/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1096,9 +1096,9 @@ impl fmt::Display for clean::ImportSource {
10961096
impl fmt::Display for clean::TypeBinding {
10971097
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10981098
if f.alternate() {
1099-
write!(f, "{}={:#}", self.name, self.ty)
1099+
write!(f, "{} = {:#}", self.name, self.ty)
11001100
} else {
1101-
write!(f, "{}={}", self.name, self.ty)
1101+
write!(f, "{} = {}", self.name, self.ty)
11021102
}
11031103
}
11041104
}

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
28082808
}
28092809
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
28102810
write!(w, "<h2 id='deref-methods'>Methods from \
2811-
{}&lt;Target={}&gt;</h2>", trait_, type_)?;
2811+
{}&lt;Target = {}&gt;</h2>", trait_, type_)?;
28122812
RenderMode::ForDeref { mut_: deref_mut_ }
28132813
}
28142814
};

src/test/rustdoc/doc-assoc-item.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct Foo<T> {
12+
x: T,
13+
}
14+
15+
pub trait Bar {
16+
type Fuu;
17+
18+
fn foo(foo: Self::Fuu);
19+
}
20+
21+
// @has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl<T: Bar<Fuu = u32>> Foo<T>'
22+
impl<T: Bar<Fuu = u32>> Foo<T> {
23+
pub fn new(t: T) -> Foo<T> {
24+
Foo {
25+
x: t,
26+
}
27+
}
28+
}

src/test/rustdoc/issue-20646.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ pub trait Trait {
2323
}
2424

2525
// @has issue_20646/fn.fun.html \
26-
// '//*[@class="rust fn"]' 'where T: Trait<Output=i32>'
26+
// '//*[@class="rust fn"]' 'where T: Trait<Output = i32>'
2727
pub fn fun<T>(_: T) where T: Trait<Output=i32> {}
2828

2929
pub mod reexport {
3030
// @has issue_20646/reexport/trait.Trait.html \
3131
// '//*[@id="associatedtype.Output"]' \
3232
// 'type Output'
3333
// @has issue_20646/reexport/fn.fun.html \
34-
// '//*[@class="rust fn"]' 'where T: Trait<Output=i32>'
34+
// '//*[@class="rust fn"]' 'where T: Trait<Output = i32>'
3535
pub use issue_20646::{Trait, fun};
3636
}

0 commit comments

Comments
 (0)