diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-09-22 18:25:55 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-22 18:25:55 +0530 |
| commit | 83bea3ddecd9222fe1e453712ece5e20834077b9 (patch) | |
| tree | a86b2b915f96e7216a80755dae44116deae37f25 /src | |
| parent | 7cac18e1be19a3f47dedec0d1115e0df511414e0 (diff) | |
| parent | e214385a4d1933ddb6a4c6ffeed50c7228674656 (diff) | |
| download | rust-83bea3ddecd9222fe1e453712ece5e20834077b9.tar.gz rust-83bea3ddecd9222fe1e453712ece5e20834077b9.zip | |
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:  After:  r? `@GuillaumeGomez`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/format.rs | 2 | ||||
| -rw-r--r-- | src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html | 7 | ||||
| -rw-r--r-- | src/test/rustdoc/where.rs | 12 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ec6b8c2469c..b499e186cc0 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -371,7 +371,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>( format!("<br><span class=\"where\">where{where_preds}</span>") } else { let mut clause = br_with_padding; - clause.truncate(clause.len() - 5 * " ".len()); + clause.truncate(clause.len() - 4 * " ".len()); write!(clause, "<span class=\"where\">where{where_preds}</span>")?; clause } diff --git a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html index 0fbdc0c9cd1..24ab77703d1 100644 --- a/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html +++ b/src/test/rustdoc/where.SWhere_TraitWhere_item-decl.html @@ -1,3 +1,8 @@ <div class="item-decl"><pre class="rust trait"><code>pub trait TraitWhere { - type <a href="#associatedtype.Item" class="associatedtype">Item</a><'a><br />   <span class="where">where<br />        Self: 'a</span>; + type <a href="#associatedtype.Item" class="associatedtype">Item</a><'a><br />    <span class="where">where<br />        Self: 'a</span>; + + fn <a href="#method.func" class="fnname">func</a>(self)<br />    <span class="where">where<br />        Self: <a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>, + { ... } +<span class="item-spacer" /> fn <a href="#method.lines" class="fnname">lines</a>(self) -> <a class="struct" href="{{channel}}/std/io/struct.Lines.html" title="struct std::io::Lines">Lines</a><Self><br />    <span class="where">where<br />        Self: <a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>, + { ... } }</code></pre></div> \ No newline at end of file diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs index 8818d74ddd0..68a146bfa55 100644 --- a/src/test/rustdoc/where.rs +++ b/src/test/rustdoc/where.rs @@ -1,5 +1,7 @@ #![crate_name = "foo"] +use std::io::Lines; + pub trait MyTrait { fn dummy(&self) { } } // @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_)where A: MyTrait" @@ -29,6 +31,16 @@ where // @snapshot SWhere_TraitWhere_item-decl - '//div[@class="item-decl"]' pub trait TraitWhere { type Item<'a> where Self: 'a; + + fn func(self) + where + Self: Sized + {} + + fn lines(self) -> Lines<Self> + where + Self: Sized, + { todo!() } } // @has foo/struct.Echo.html '//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ |
