File tree Expand file tree Collapse file tree 3 files changed +4226
-4146
lines changed
rust/ql/test/library-tests/type-inference Expand file tree Collapse file tree 3 files changed +4226
-4146
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ multipleCallTargets
99| main.rs:590:9:590:18 | ...::m(...) |
1010| main.rs:591:9:591:20 | ... .m() |
1111| main.rs:592:9:592:24 | ...::m(...) |
12- | main.rs:2524 :13:2524 :31 | ...::from(...) |
13- | main.rs:2525 :13:2525 :31 | ...::from(...) |
14- | main.rs:2526 :13:2526 :31 | ...::from(...) |
15- | main.rs:2532 :13:2532 :31 | ...::from(...) |
16- | main.rs:2533 :13:2533 :31 | ...::from(...) |
17- | main.rs:2534 :13:2534 :31 | ...::from(...) |
12+ | main.rs:2553 :13:2553 :31 | ...::from(...) |
13+ | main.rs:2554 :13:2554 :31 | ...::from(...) |
14+ | main.rs:2555 :13:2555 :31 | ...::from(...) |
15+ | main.rs:2561 :13:2561 :31 | ...::from(...) |
16+ | main.rs:2562 :13:2562 :31 | ...::from(...) |
17+ | main.rs:2563 :13:2563 :31 | ...::from(...) |
Original file line number Diff line number Diff line change @@ -758,6 +758,26 @@ mod function_trait_bounds {
758758 fn assoc ( x : Self ) -> A ;
759759 }
760760
761+ impl < T : Default > MyTrait < T > for S2 {
762+ fn m1 ( self ) -> T {
763+ Default :: default ( ) // $ target=default
764+ }
765+
766+ fn assoc ( x : Self ) -> T {
767+ Default :: default ( ) // $ target=default
768+ }
769+ }
770+
771+ impl MyTrait < i32 > for S1 {
772+ fn m1 ( self ) -> i32 {
773+ 0
774+ }
775+
776+ fn assoc ( x : Self ) -> i32 {
777+ 0
778+ }
779+ }
780+
761781 // Type parameter with bound occurs in the root of a parameter type.
762782
763783 fn call_trait_m1 < T1 , T2 : MyTrait < T1 > + Copy > ( x : T2 ) -> T1 {
@@ -863,6 +883,8 @@ mod function_trait_bounds {
863883 println ! ( "{:?}" , b) ;
864884 let b = call_trait_thing_m1_3 ( y3) ; // $ type=b:S2 target=call_trait_thing_m1_3
865885 println ! ( "{:?}" , b) ;
886+ let x = S1 :: m2 ( S1 ) ; // $ target=m2 $ type=x:i32
887+ let y: i32 = S2 :: m2 ( S2 ) ; // $ target=m2
866888 }
867889}
868890
@@ -1576,11 +1598,18 @@ mod implicit_self_borrow {
15761598 fn foo ( & self ) -> & Self {
15771599 self
15781600 }
1601+
1602+ fn bar ( & self , x : & Self ) -> & Self {
1603+ self
1604+ }
15791605 }
15801606
15811607 pub fn f ( ) {
15821608 let x = MyStruct ( S ) ;
15831609 x. foo ( ) ; // $ target=foo
1610+ let x = MyStruct ( S ) ;
1611+ // `&&x` below is Deref coerced to `&x` (see https://doc.rust-lang.org/std/ops/trait.Deref.html#deref-coercion)
1612+ x. bar ( & & x) ; // $ target=bar
15841613 }
15851614}
15861615
You can’t perform that action at this time.
0 commit comments