@@ -1099,6 +1099,7 @@ mod method_call_type_conversion {
1099
1099
println ! ( "{:?}" , x5. 0 ) ; // $ fieldof=S
1100
1100
1101
1101
let x6 = & S ( S2 ) ; // $ SPURIOUS: type=x6:&T.&T.S
1102
+
1102
1103
// explicit dereference
1103
1104
println ! ( "{:?}" , ( * x6) . m1( ) ) ; // $ method=m1 method=deref
1104
1105
@@ -1668,17 +1669,18 @@ mod async_ {
1668
1669
}
1669
1670
1670
1671
fn f2 ( ) -> impl Future < Output = S1 > {
1671
- async {
1672
- S1
1673
- }
1672
+ async { S1 }
1674
1673
}
1675
1674
1676
1675
struct S2 ;
1677
1676
1678
1677
impl Future for S2 {
1679
1678
type Output = S1 ;
1680
1679
1681
- fn poll ( self : std:: pin:: Pin < & mut Self > , _cx : & mut std:: task:: Context < ' _ > ) -> std:: task:: Poll < Self :: Output > {
1680
+ fn poll (
1681
+ self : std:: pin:: Pin < & mut Self > ,
1682
+ _cx : & mut std:: task:: Context < ' _ > ,
1683
+ ) -> std:: task:: Poll < Self :: Output > {
1682
1684
std:: task:: Poll :: Ready ( S1 )
1683
1685
}
1684
1686
}
@@ -1692,14 +1694,11 @@ mod async_ {
1692
1694
f2 ( ) . await . f ( ) ; // $ method=S1f
1693
1695
f3 ( ) . await . f ( ) ; // $ method=S1f
1694
1696
S2 . await . f ( ) ; // $ method=S1f
1695
- let b = async {
1696
- S1
1697
- } ;
1697
+ let b = async { S1 } ;
1698
1698
b. await . f ( ) ; // $ method=S1f
1699
1699
}
1700
1700
}
1701
1701
1702
-
1703
1702
mod impl_trait {
1704
1703
struct S1 ;
1705
1704
struct S2 ;
@@ -1816,6 +1815,44 @@ mod macros {
1816
1815
}
1817
1816
}
1818
1817
1818
+ mod method_determined_by_argument_type {
1819
+ trait MyAdd < T > {
1820
+ fn my_add ( & self , value : T ) -> Self ;
1821
+ }
1822
+
1823
+ impl MyAdd < i64 > for i64 {
1824
+ // MyAdd<i64>::my_add
1825
+ fn my_add ( & self , value : i64 ) -> Self {
1826
+ value
1827
+ }
1828
+ }
1829
+
1830
+ impl MyAdd < & i64 > for i64 {
1831
+ // MyAdd<&i64>::my_add
1832
+ fn my_add ( & self , value : & i64 ) -> Self {
1833
+ * value // $ method=deref
1834
+ }
1835
+ }
1836
+
1837
+ impl MyAdd < bool > for i64 {
1838
+ // MyAdd<bool>::my_add
1839
+ fn my_add ( & self , value : bool ) -> Self {
1840
+ if value {
1841
+ 1
1842
+ } else {
1843
+ 0
1844
+ }
1845
+ }
1846
+ }
1847
+
1848
+ pub fn f ( ) {
1849
+ let x: i64 = 73 ;
1850
+ x. my_add ( 5i64 ) ; // $ method=MyAdd<i64>::my_add SPURIOUS: method=MyAdd<bool>::my_add SPURIOUS: method=MyAdd<&i64>::my_add
1851
+ x. my_add ( & 5i64 ) ; // $ method=MyAdd<&i64>::my_add SPURIOUS: method=MyAdd<i64>::my_add SPURIOUS: method=MyAdd<bool>::my_add
1852
+ x. my_add ( true ) ; // $ method=MyAdd<bool>::my_add SPURIOUS: method=MyAdd<i64>::my_add SPURIOUS: method=MyAdd<&i64>::my_add
1853
+ }
1854
+ }
1855
+
1819
1856
fn main ( ) {
1820
1857
field_access:: f ( ) ;
1821
1858
method_impl:: f ( ) ;
@@ -1839,4 +1876,5 @@ fn main() {
1839
1876
impl_trait:: f ( ) ;
1840
1877
indexers:: f ( ) ;
1841
1878
macros:: f ( ) ;
1879
+ method_determined_by_argument_type:: f ( ) ;
1842
1880
}
0 commit comments