|
| 1 | +// ignore-tidy-linelength |
| 2 | + |
| 3 | +pub struct Foo; |
| 4 | + |
| 5 | +// Check that Self is represented uniformly between inherent impls, trait impls, |
| 6 | +// and trait definitions, even though it uses both SelfTyParam and SelfTyAlias |
| 7 | +// internally. |
| 8 | +// |
| 9 | +// Each assertion matches 3 times, and should be the same each time. |
| 10 | + |
| 11 | +impl Foo { |
| 12 | + //@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"' |
| 13 | + //@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][1].borrowed_ref.type.generic' '"Self"' '"Self"' '"Self"' |
| 14 | + //@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][1].borrowed_ref.lifetime' null null null |
| 15 | + //@ ismany '$.index[*][?(@.name=="by_ref")].inner.function.decl.inputs[0][1].borrowed_ref.mutable' false false false |
| 16 | + pub fn by_ref(&self) {} |
| 17 | + |
| 18 | + //@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"' |
| 19 | + //@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][1].borrowed_ref.type.generic' '"Self"' '"Self"' '"Self"' |
| 20 | + //@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][1].borrowed_ref.lifetime' null null null |
| 21 | + //@ ismany '$.index[*][?(@.name=="by_exclusive_ref")].inner.function.decl.inputs[0][1].borrowed_ref.mutable' true true true |
| 22 | + pub fn by_exclusive_ref(&mut self) {} |
| 23 | + |
| 24 | + //@ ismany '$.index[*][?(@.name=="by_value")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"' |
| 25 | + //@ ismany '$.index[*][?(@.name=="by_value")].inner.function.decl.inputs[0][1].generic' '"Self"' '"Self"' '"Self"' |
| 26 | + pub fn by_value(self) {} |
| 27 | + |
| 28 | + //@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][0]' '"self"' '"self"' '"self"' |
| 29 | + //@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][1].borrowed_ref.type.generic' '"Self"' '"Self"' '"Self"' |
| 30 | + //@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][1].borrowed_ref.lifetime' \"\'a\" \"\'a\" \"\'a\" |
| 31 | + //@ ismany '$.index[*][?(@.name=="with_lifetime")].inner.function.decl.inputs[0][1].borrowed_ref.mutable' false false false |
| 32 | + pub fn with_lifetime<'a>(&'a self) {} |
| 33 | + |
| 34 | + //@ ismany '$.index[*][?(@.name=="build")].inner.function.decl.output.generic' '"Self"' '"Self"' '"Self"' |
| 35 | + pub fn build() -> Self { |
| 36 | + Self |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +pub struct Bar; |
| 41 | + |
| 42 | +pub trait SelfParams { |
| 43 | + fn by_ref(&self); |
| 44 | + fn by_exclusive_ref(&mut self); |
| 45 | + fn by_value(self); |
| 46 | + fn with_lifetime<'a>(&'a self); |
| 47 | + fn build() -> Self; |
| 48 | +} |
| 49 | + |
| 50 | +impl SelfParams for Bar { |
| 51 | + fn by_ref(&self) {} |
| 52 | + fn by_exclusive_ref(&mut self) {} |
| 53 | + fn by_value(self) {} |
| 54 | + fn with_lifetime<'a>(&'a self) {} |
| 55 | + fn build() -> Self { |
| 56 | + Self |
| 57 | + } |
| 58 | +} |
0 commit comments