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="rust item-decl"]' 8 pub trait ToOwned<T> 9 where T: Clone 10 { 11 type Owned; to_owned(&self) -> Self::Owned12 fn to_owned(&self) -> Self::Owned; whatever(&self) -> T13 fn whatever(&self) -> T; 14 } 15 16 // @has 'foo/trait.ToOwned2.html' 17 // @snapshot trait2 - '//*[@class="rust item-decl"]' 18 // There should be a whitespace before `{` in this case! 19 pub trait ToOwned2<T: Clone> { 20 type Owned; to_owned(&self) -> Self::Owned21 fn to_owned(&self) -> Self::Owned; whatever(&self) -> T22 fn whatever(&self) -> T; 23 } 24 25 // @has 'foo/enum.Cow.html' 26 // @snapshot enum - '//*[@class="rust 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="rust 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="rust 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="rust 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="rust 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="rust 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 } 78