Skip to content

Commit 87a8dcc

Browse files
authored
Merge pull request #20037 from paldepind/rust/type-inference-rename-expectations
Rust: Rename type inference test inline expectation tag
2 parents c941e91 + 7285453 commit 87a8dcc

File tree

7 files changed

+538
-536
lines changed

7 files changed

+538
-536
lines changed

rust/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ private import codeql.util.test.InlineExpectationsTest
44

55
module Impl implements InlineExpectationsTestSig {
66
class ExpectationComment extends R::Comment {
7+
ExpectationComment() { this.fromSource() }
8+
79
/** Gets the contents of the given comment, _without_ the preceding comment marker (`//`). */
810
string getContents() { result = this.getCommentText() }
911
}

rust/ql/test/library-tests/type-inference/dereference.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,73 +30,73 @@ impl<T> Deref for MySmartPointer<T> {
3030
fn explicit_monomorphic_dereference() {
3131
// Dereference with method call
3232
let a1 = MyIntPointer { value: 34i64 };
33-
let _b1 = a1.deref(); // $ method=MyIntPointer::deref type=_b1:&T.i64
33+
let _b1 = a1.deref(); // $ target=MyIntPointer::deref type=_b1:&T.i64
3434

3535
// Dereference with overloaded dereference operator
3636
let a2 = MyIntPointer { value: 34i64 };
37-
let _b2 = *a2; // $ method=MyIntPointer::deref type=_b2:i64
37+
let _b2 = *a2; // $ target=MyIntPointer::deref type=_b2:i64
3838

3939
// Call method on explicitly dereferenced value
4040
let a3 = MyIntPointer { value: 34i64 };
41-
let _b3 = (*a3).is_positive(); // $ method=MyIntPointer::deref method=is_positive type=_b3:bool
41+
let _b3 = (*a3).is_positive(); // $ target=MyIntPointer::deref target=is_positive type=_b3:bool
4242
}
4343

4444
fn explicit_polymorphic_dereference() {
4545
// Explicit dereference with type parameter
4646
let c1 = MySmartPointer { value: 'a' };
47-
let _d1 = c1.deref(); // $ method=MySmartPointer::deref type=_d1:&T.char
47+
let _d1 = c1.deref(); // $ target=MySmartPointer::deref type=_d1:&T.char
4848

4949
// Explicit dereference with type parameter
5050
let c2 = MySmartPointer { value: 'a' };
51-
let _d2 = *c2; // $ method=MySmartPointer::deref type=_d2:char
51+
let _d2 = *c2; // $ target=MySmartPointer::deref type=_d2:char
5252

5353
// Call method on explicitly dereferenced value with type parameter
5454
let c3 = MySmartPointer { value: 34i64 };
55-
let _d3 = (*c3).is_positive(); // $ method=MySmartPointer::deref method=is_positive type=_d3:bool
55+
let _d3 = (*c3).is_positive(); // $ target=MySmartPointer::deref target=is_positive type=_d3:bool
5656
}
5757

5858
fn explicit_ref_dereference() {
5959
// Explicit dereference with type parameter
6060
let e1 = &'a';
61-
let _f1 = e1.deref(); // $ method=deref MISSING: type=_f1:&T.char
61+
let _f1 = e1.deref(); // $ target=deref MISSING: type=_f1:&T.char
6262

6363
// Explicit dereference with type parameter
6464
let e2 = &'a';
65-
let _f2 = *e2; // $ method=deref type=_f2:char
65+
let _f2 = *e2; // $ target=deref type=_f2:char
6666

6767
// Call method on explicitly dereferenced value with type parameter
6868
let e3 = &34i64;
69-
let _f3 = (*e3).is_positive(); // $ method=deref method=is_positive type=_f3:bool
69+
let _f3 = (*e3).is_positive(); // $ target=deref target=is_positive type=_f3:bool
7070
}
7171

7272
fn explicit_box_dereference() {
7373
// Explicit dereference with type parameter
74-
let g1: Box<char> = Box::new('a'); // $ method=new
75-
let _h1 = g1.deref(); // $ method=deref type=_h1:&T.char
74+
let g1: Box<char> = Box::new('a'); // $ target=new
75+
let _h1 = g1.deref(); // $ target=deref type=_h1:&T.char
7676

7777
// Explicit dereference with type parameter
78-
let g2: Box<char> = Box::new('a'); // $ method=new
79-
let _h2 = *g2; // $ method=deref type=_h2:char
78+
let g2: Box<char> = Box::new('a'); // $ target=new
79+
let _h2 = *g2; // $ target=deref type=_h2:char
8080

8181
// Call method on explicitly dereferenced value with type parameter
82-
let g3: Box<i64> = Box::new(34i64); // $ method=new
83-
let _h3 = (*g3).is_positive(); // $ method=deref method=is_positive type=_h3:bool
82+
let g3: Box<i64> = Box::new(34i64); // $ target=new
83+
let _h3 = (*g3).is_positive(); // $ target=deref target=is_positive type=_h3:bool
8484
}
8585

8686
fn implicit_dereference() {
8787
// Call method on implicitly dereferenced value
8888
let x = MyIntPointer { value: 34i64 };
89-
let _y = x.is_positive(); // $ MISSING: method=is_positive type=_y:bool
89+
let _y = x.is_positive(); // $ MISSING: target=is_positive type=_y:bool
9090

9191
// Call method on implicitly dereferenced value
9292
let x = MySmartPointer { value: 34i64 };
93-
let _y = x.is_positive(); // $ MISSING: method=is_positive type=_y:bool
93+
let _y = x.is_positive(); // $ MISSING: target=is_positive type=_y:bool
9494
}
9595

9696
pub fn test() {
97-
explicit_monomorphic_dereference(); // $ method=explicit_monomorphic_dereference
98-
explicit_polymorphic_dereference(); // $ method=explicit_polymorphic_dereference
99-
explicit_ref_dereference(); // $ method=explicit_ref_dereference
100-
explicit_box_dereference(); // $ method=explicit_box_dereference
101-
implicit_dereference(); // $ method=implicit_dereference
97+
explicit_monomorphic_dereference(); // $ target=explicit_monomorphic_dereference
98+
explicit_polymorphic_dereference(); // $ target=explicit_polymorphic_dereference
99+
explicit_ref_dereference(); // $ target=explicit_ref_dereference
100+
explicit_box_dereference(); // $ target=explicit_box_dereference
101+
implicit_dereference(); // $ target=implicit_dereference
102102
}

rust/ql/test/library-tests/type-inference/loop/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ trait T1<T>: T2<S<T>> {
99

1010
trait T2<T>: T1<S<T>> {
1111
fn bar(self) {
12-
self.foo() // $ method=foo
12+
self.foo() // $ target=foo
1313
}
1414
}

0 commit comments

Comments
 (0)