File tree Expand file tree Collapse file tree 2 files changed +591
-534
lines changed
rust/ql/test/library-tests/type-inference Expand file tree Collapse file tree 2 files changed +591
-534
lines changed Original file line number Diff line number Diff line change 11/// This file contains tests for dereferencing with through the `Deref` trait.
22use std:: ops:: Deref ;
3+ use std:: ops:: DerefMut ;
34
45struct MyIntPointer {
56 value : i64 ,
@@ -27,6 +28,13 @@ impl<T> Deref for MySmartPointer<T> {
2728 }
2829}
2930
31+ impl < T > DerefMut for MySmartPointer < T > {
32+ // MySmartPointer::deref_mut
33+ fn deref_mut ( & mut self ) -> & mut T {
34+ & mut self . value // $ fieldof=MySmartPointer
35+ }
36+ }
37+
3038struct S < T > ( T ) ;
3139
3240impl < T > S < T > {
@@ -102,6 +110,10 @@ fn implicit_dereference() {
102110
103111 let z = MySmartPointer { value : S ( 0i64 ) } ;
104112 let z_ = z. foo ( ) ; // $ MISSING: target=foo type=z_:TRef.i64
113+
114+ let v = Vec :: new ( ) ; // $ target=new $ MISSING: type=x:T.i32
115+ let mut x = MySmartPointer { value : v } ;
116+ x. push ( 0 ) ; // $ MISSING: target=push
105117}
106118
107119mod implicit_deref_coercion_cycle {
You can’t perform that action at this time.
0 commit comments