Skip to content

Commit ce1b41c

Browse files
committed
Rust: Use type inference in path resolution test
1 parent e370659 commit ce1b41c

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

rust/ql/test/library-tests/path-resolution/main.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ mod m8 {
184184
> // $ MISSING: item=52
185185
::f(&x); // $ MISSING: item=I53
186186
let x = MyStruct {}; // $ item=I50
187-
x.f(); // $ MISSING: item=I53
187+
x.f(); // $ item=I53
188188
let x = MyStruct {}; // $ item=I50
189-
x.g(); // $ MISSING: item=I54
189+
x.g(); // $ item=I54
190190
MyStruct::h(&x); // $ item=I74
191-
x.h(); // $ MISSING: item=I74
191+
x.h(); // $ item=I74
192192
} // I55
193193
} // I46
194194

@@ -304,7 +304,7 @@ mod m15 {
304304
fn f(&self) {
305305
println!("m15::Trait2::f");
306306
Self::g(self); // $ item=I80
307-
self.g(); // $ MISSING: item=I80
307+
self.g(); // $ item=I80
308308
}
309309
} // I82
310310

@@ -316,7 +316,7 @@ mod m15 {
316316
fn f(&self) {
317317
println!("m15::<S as Trait1>::f");
318318
Self::g(self); // $ item=I77
319-
self.g(); // $ MISSING: item=I77
319+
self.g(); // $ item=I77
320320
} // I76
321321

322322
fn g(&self) {
@@ -343,7 +343,7 @@ mod m15 {
343343
as Trait2 // $ item=I82
344344
>::f(&x); // $ MISSING: item=I78
345345
S::g(&x); // $ item=I77
346-
x.g(); // $ MISSING: item=I77
346+
x.g(); // $ item=I77
347347
} // I75
348348
}
349349

@@ -359,7 +359,7 @@ mod m16 {
359359

360360
fn h(&self) -> T { // $ item=I84
361361
Self::g(&self); // $ item=I85
362-
self.g() // $ MISSING: item=I85
362+
self.g() // $ item=I85
363363
} // I96
364364

365365
const c: T // $ item=I84
@@ -376,7 +376,7 @@ mod m16 {
376376
fn f(&self) -> T { // $ item=I87
377377
println!("m16::Trait2::f");
378378
Self::g(self); // $ item=I85
379-
self.g(); // $ MISSING: item=I85
379+
self.g(); // $ item=I85
380380
Self::c // $ item=I94
381381
}
382382
} // I89
@@ -391,7 +391,7 @@ mod m16 {
391391
fn f(&self) -> S { // $ item=I90
392392
println!("m16::<S as Trait1<S>>::f");
393393
Self::g(self); // $ item=I92
394-
self.g() // $ MISSING: item=I92
394+
self.g() // $ item=I92
395395
} // I91
396396

397397
fn g(&self) -> S { // $ item=I90
@@ -429,9 +429,9 @@ mod m16 {
429429
> // $ item=I89
430430
>::f(&x); // $ MISSING: item=I93
431431
S::g(&x); // $ item=I92
432-
x.g(); // $ MISSING: item=I92
432+
x.g(); // $ item=I92
433433
S::h(&x); // $ item=I96
434-
x.h(); // $ MISSING: item=I96
434+
x.h(); // $ item=I96
435435
S::c; // $ item=I95
436436
<S // $ item=I90
437437
as Trait1<
@@ -460,7 +460,7 @@ mod m17 {
460460
fn g<T: // I5
461461
MyTrait // $ item=I2
462462
>(x: T) { // $ item=I5
463-
x.f(); // $ MISSING: item=I1
463+
x.f(); // $ item=I1
464464
T::f(&x); // $ item=I1
465465
MyTrait::f(&x); // $ item=I1
466466
} // I6

rust/ql/test/library-tests/path-resolution/path-resolution.ql

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import rust
22
import codeql.rust.elements.internal.PathResolution
3+
import codeql.rust.elements.internal.TypeInference
34
import utils.test.InlineExpectationsTest
45

56
query predicate mod(Module m) { any() }
@@ -31,12 +32,15 @@ module ResolveTest implements TestSig {
3132
}
3233

3334
predicate hasActualResult(Location location, string element, string tag, string value) {
34-
exists(Path p |
35-
not p = any(Path parent).getQualifier() and
36-
location = p.getLocation() and
37-
element = p.toString() and
38-
item(resolvePath(p), value) and
35+
exists(AstNode n |
36+
not n = any(Path parent).getQualifier() and
37+
location = n.getLocation() and
38+
element = n.toString() and
3939
tag = "item"
40+
|
41+
item(resolvePath(n), value)
42+
or
43+
item(n.(MethodCallExpr).getStaticTarget(), value)
4044
)
4145
}
4246
}

0 commit comments

Comments
 (0)