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