Skip to content

Commit c8a5b67

Browse files
Add test for invalid whitespace display after where clause
1 parent c748551 commit c8a5b67

9 files changed

+111
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="docblock item-decl"><pre class="rust enum"><code>pub enum Cow&lt;'a, B:&#160;?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a&gt; <span class="where fmt-newline">where<br />&#160;&#160;&#160;&#160;B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt;,&#160;</span>{
2+
Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a </a>B),
3+
Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>),
4+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="docblock item-decl"><pre class="rust enum"><code>pub enum Cow2&lt;'a, B:&#160;?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + 'a&gt; {
2+
Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a </a>B),
3+
Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>),
4+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This test ensures there is no whitespace before the first brace of
2+
// trait, enum, struct and union items when they have a where clause.
3+
4+
#![crate_name = "foo"]
5+
6+
// @has 'foo/trait.ToOwned.html'
7+
// @snapshot trait - '//*[@class="docblock item-decl"]'
8+
pub trait ToOwned<T>
9+
where T: Clone
10+
{
11+
type Owned;
12+
fn to_owned(&self) -> Self::Owned;
13+
fn whatever(&self) -> T;
14+
}
15+
16+
// @has 'foo/trait.ToOwned2.html'
17+
// @snapshot trait2 - '//*[@class="docblock item-decl"]'
18+
// There should be a whitespace before `{` in this case!
19+
pub trait ToOwned2<T: Clone> {
20+
type Owned;
21+
fn to_owned(&self) -> Self::Owned;
22+
fn whatever(&self) -> T;
23+
}
24+
25+
// @has 'foo/enum.Cow.html'
26+
// @snapshot enum - '//*[@class="docblock item-decl"]'
27+
pub enum Cow<'a, B: ?Sized + 'a>
28+
where
29+
B: ToOwned<Clone>,
30+
{
31+
Borrowed(&'a B),
32+
Whatever(u32),
33+
}
34+
35+
// @has 'foo/enum.Cow2.html'
36+
// @snapshot enum2 - '//*[@class="docblock item-decl"]'
37+
// There should be a whitespace before `{` in this case!
38+
pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
39+
Borrowed(&'a B),
40+
Whatever(u32),
41+
}
42+
43+
// @has 'foo/struct.Struct.html'
44+
// @snapshot struct - '//*[@class="docblock item-decl"]'
45+
pub struct Struct<'a, B: ?Sized + 'a>
46+
where
47+
B: ToOwned<Clone>,
48+
{
49+
pub a: &'a B,
50+
pub b: u32,
51+
}
52+
53+
// @has 'foo/struct.Struct2.html'
54+
// @snapshot struct2 - '//*[@class="docblock item-decl"]'
55+
// There should be a whitespace before `{` in this case!
56+
pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
57+
pub a: &'a B,
58+
pub b: u32,
59+
}
60+
61+
// @has 'foo/union.Union.html'
62+
// @snapshot union - '//*[@class="docblock item-decl"]'
63+
pub union Union<'a, B: ?Sized + 'a>
64+
where
65+
B: ToOwned<Clone>,
66+
{
67+
a: &'a B,
68+
b: u32,
69+
}
70+
71+
// @has 'foo/union.Union2.html'
72+
// @snapshot union2 - '//*[@class="docblock item-decl"]'
73+
// There should be a whitespace before `{` in this case!
74+
pub union Union2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
75+
a: &'a B,
76+
b: u32,
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Struct&lt;'a, B:&#160;?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a&gt; <span class="where fmt-newline">where<br />&#160;&#160;&#160;&#160;B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt;,&#160;</span>{
2+
pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a </a>B,
3+
pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>,
4+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="docblock item-decl"><pre class="rust struct"><code>pub struct Struct2&lt;'a, B:&#160;?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + 'a&gt; {
2+
pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a </a>B,
3+
pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>,
4+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="docblock item-decl"><pre class="rust trait"><code>pub trait ToOwned&lt;T&gt; <span class="where fmt-newline">where<br />&#160;&#160;&#160;&#160;T: <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&#160;</span>{
2+
type <a href="#associatedtype.Owned" class="associatedtype">Owned</a>;
3+
4+
fn <a href="#tymethod.to_owned" class="fnname">to_owned</a>(&amp;self) -&gt; Self::<a class="associatedtype" href="trait.ToOwned.html#associatedtype.Owned" title="type foo::ToOwned::Owned">Owned</a>;
5+
<span class="item-spacer" /> fn <a href="#tymethod.whatever" class="fnname">whatever</a>(&amp;self) -&gt; T;
6+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="docblock item-decl"><pre class="rust trait"><code>pub trait ToOwned2&lt;T:&#160;<a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; {
2+
type <a href="#associatedtype.Owned" class="associatedtype">Owned</a>;
3+
4+
fn <a href="#tymethod.to_owned" class="fnname">to_owned</a>(&amp;self) -&gt; Self::<a class="associatedtype" href="trait.ToOwned2.html#associatedtype.Owned" title="type foo::ToOwned2::Owned">Owned</a>;
5+
<span class="item-spacer" /> fn <a href="#tymethod.whatever" class="fnname">whatever</a>(&amp;self) -&gt; T;
6+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="docblock item-decl"><pre class="rust union"><code>pub union Union&lt;'a, B:&#160;?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a&gt; <span class="where fmt-newline">where<br />&#160;&#160;&#160;&#160;B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt;,&#160;</span>{
2+
/* private fields */
3+
}</code></pre></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="docblock item-decl"><pre class="rust union"><code>pub union Union2&lt;'a, B:&#160;?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + 'a&gt; {
2+
/* private fields */
3+
}</code></pre></div>

0 commit comments

Comments
 (0)