Skip to content

Commit f6c7f10

Browse files
committed
Remove extra space before a where clause in the documentation
1 parent dc1f829 commit f6c7f10

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/librustdoc/html/format.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
371371
clause = clause.replace("<br>", &format!("<br>{}", padding));
372372
clause.insert_str(0, &"&nbsp;".repeat(indent.saturating_sub(1)));
373373
if !end_newline {
374-
clause.insert_str(0, "<br>");
374+
// we insert the <br> after a single space but before multiple spaces at the start
375+
clause.insert_str(if indent == 0 { 1 } else { 0 }, "<br>");
375376
}
376377
}
377378
write!(f, "{}", clause)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Simd&lt;T, const LANES:&#160;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;(_) <br /><span class="where">where<br />&#160;&#160;&#160;&#160;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>;</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="docblock item-decl"><pre class="rust trait"><code>pub trait TraitWhere {
2+
type <a href="#associatedtype.Item" class="associatedtype">Item</a>&lt;'a&gt;<br />&#160;&#160;&#160; <span class="where">where<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Self: 'a</span>;
3+
}</code></pre></div>

src/test/rustdoc/where.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(generic_associated_types)]
12
#![crate_name = "foo"]
23

34
pub trait MyTrait { fn dummy(&self) { } }
@@ -19,6 +20,18 @@ impl<D> Delta<D> where D: MyTrait {
1920

2021
pub struct Echo<E>(E);
2122

23+
// @has 'foo/struct.Simd.html'
24+
// @snapshot SWhere_Simd_item-decl - '//div[@class="docblock item-decl"]'
25+
pub struct Simd<T, const LANES: usize>([T; LANES])
26+
where
27+
T: Sized;
28+
29+
// @has 'foo/trait.TraitWhere.html'
30+
// @snapshot SWhere_TraitWhere_item-decl - '//div[@class="docblock item-decl"]'
31+
pub trait TraitWhere {
32+
type Item<'a> where Self: 'a;
33+
}
34+
2235
// @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \
2336
// "impl<E> MyTrait for Echo<E> where E: MyTrait"
2437
// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header in-band"]' \

0 commit comments

Comments
 (0)