Skip to content

Commit 83bea3d

Browse files
authored
Rollup merge of #102107 - Urgau:rustdoc-missing-space-before-where-clause, r=GuillaumeGomez
Add missing space between notable trait tooltip and where clause This PR add a missing space between the notable trait tooltip and the where clause. The issue can be seeing on the [BufRead](https://doc.rust-lang.org/nightly/std/io/trait.BufRead.html) page. Added a simple snapshot regression test in `src/test/rustdoc/where.rs`. Before: ![image](https://user-images.githubusercontent.com/3616612/191566999-2f80e138-29c9-4f66-8bed-07781cbd9783.png) After: ![image](https://user-images.githubusercontent.com/3616612/191567025-0ed3f7d4-7cec-4788-901f-5980fc241daa.png) r? `@GuillaumeGomez`
2 parents 7cac18e + e214385 commit 83bea3d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
371371
format!("<br><span class=\"where\">where{where_preds}</span>")
372372
} else {
373373
let mut clause = br_with_padding;
374-
clause.truncate(clause.len() - 5 * "&nbsp;".len());
374+
clause.truncate(clause.len() - 4 * "&nbsp;".len());
375375
write!(clause, "<span class=\"where\">where{where_preds}</span>")?;
376376
clause
377377
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
<div class="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>;
2+
type <a href="#associatedtype.Item" class="associatedtype">Item</a>&lt;'a&gt;<br />&#160;&#160;&#160;&#160;<span class="where">where<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Self: 'a</span>;
3+
4+
fn <a href="#method.func" class="fnname">func</a>(self)<br />&#160;&#160;&#160;&#160;<span class="where">where<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Self: <a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
5+
{ ... }
6+
<span class="item-spacer" /> fn <a href="#method.lines" class="fnname">lines</a>(self) -&gt; <a class="struct" href="{{channel}}/std/io/struct.Lines.html" title="struct std::io::Lines">Lines</a>&lt;Self&gt;<br />&#160;&#160;&#160;&#160;<span class="where">where<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Self: <a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
7+
{ ... }
38
}</code></pre></div>

src/test/rustdoc/where.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![crate_name = "foo"]
22

3+
use std::io::Lines;
4+
35
pub trait MyTrait { fn dummy(&self) { } }
46

57
// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_)where A: MyTrait"
@@ -29,6 +31,16 @@ where
2931
// @snapshot SWhere_TraitWhere_item-decl - '//div[@class="item-decl"]'
3032
pub trait TraitWhere {
3133
type Item<'a> where Self: 'a;
34+
35+
fn func(self)
36+
where
37+
Self: Sized
38+
{}
39+
40+
fn lines(self) -> Lines<Self>
41+
where
42+
Self: Sized,
43+
{ todo!() }
3244
}
3345

3446
// @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \

0 commit comments

Comments
 (0)