mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Rust: When resolving methods on reference also consider the reference itself
This commit is contained in:
@@ -1141,8 +1141,6 @@ final class MethodCall extends Call {
|
||||
(
|
||||
path0.isCons(TRefTypeParameter(), path)
|
||||
or
|
||||
not path0.isCons(TRefTypeParameter(), _) and
|
||||
not (path0.isEmpty() and result = TRefType()) and
|
||||
path = path0
|
||||
)
|
||||
|
|
||||
|
||||
@@ -58,7 +58,7 @@ fn explicit_polymorphic_dereference() {
|
||||
fn explicit_ref_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let e1 = &'a';
|
||||
let _f1 = e1.deref(); // $ MISSING: method=deref type=_f1:&T.char
|
||||
let _f1 = e1.deref(); // $ method=deref MISSING: type=_f1:&T.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let e2 = &'a';
|
||||
|
||||
@@ -1157,14 +1157,14 @@ mod method_call_type_conversion {
|
||||
// https://doc.rust-lang.org/std/string/struct.String.html#deref.
|
||||
let u = x9.parse::<u32>(); // $ method=parse type=u:T.u32
|
||||
|
||||
let my_thing = &MyInt { a: 37 };
|
||||
let my_thing = &MyInt { a: 37 }; // $ SPURIOUS: type=my_thing:&T.&T.MyInt
|
||||
// implicit borrow of a `&`
|
||||
let a = my_thing.method_on_borrow(); // $ MISSING: method=MyInt::method_on_borrow
|
||||
let a = my_thing.method_on_borrow(); // $ method=MyInt::method_on_borrow
|
||||
println!("{:?}", a);
|
||||
|
||||
// no implicit borrow
|
||||
let my_thing = &MyInt { a: 38 };
|
||||
let a = my_thing.method_not_on_borrow(); // $ MISSING: method=MyInt::method_not_on_borrow
|
||||
let a = my_thing.method_not_on_borrow(); // $ method=MyInt::method_not_on_borrow
|
||||
println!("{:?}", a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,11 +126,17 @@ inferType
|
||||
| dereference.rs:55:17:55:18 | c3 | T | {EXTERNAL LOCATION} | i64 |
|
||||
| dereference.rs:60:9:60:10 | e1 | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:60:9:60:10 | e1 | &T | {EXTERNAL LOCATION} | char |
|
||||
| dereference.rs:60:9:60:10 | e1 | &T | file://:0:0:0:0 | & |
|
||||
| dereference.rs:60:14:60:17 | &'a' | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:60:14:60:17 | &'a' | &T | {EXTERNAL LOCATION} | char |
|
||||
| dereference.rs:60:14:60:17 | &'a' | &T | file://:0:0:0:0 | & |
|
||||
| dereference.rs:60:15:60:17 | 'a' | | {EXTERNAL LOCATION} | char |
|
||||
| dereference.rs:60:15:60:17 | 'a' | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:61:9:61:11 | _f1 | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:61:15:61:16 | e1 | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:61:15:61:16 | e1 | &T | {EXTERNAL LOCATION} | char |
|
||||
| dereference.rs:61:15:61:16 | e1 | &T | file://:0:0:0:0 | & |
|
||||
| dereference.rs:61:15:61:24 | e1.deref() | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:64:9:64:10 | e2 | | file://:0:0:0:0 | & |
|
||||
| dereference.rs:64:9:64:10 | e2 | &T | {EXTERNAL LOCATION} | char |
|
||||
| dereference.rs:64:9:64:10 | e2 | &T | file://:0:0:0:0 | & |
|
||||
@@ -1733,15 +1739,26 @@ inferType
|
||||
| main.rs:1158:17:1158:33 | x9.parse() | | {EXTERNAL LOCATION} | Result |
|
||||
| main.rs:1158:17:1158:33 | x9.parse() | T | {EXTERNAL LOCATION} | u32 |
|
||||
| main.rs:1160:13:1160:20 | my_thing | | file://:0:0:0:0 | & |
|
||||
| main.rs:1160:13:1160:20 | my_thing | &T | file://:0:0:0:0 | & |
|
||||
| main.rs:1160:13:1160:20 | my_thing | &T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1160:13:1160:20 | my_thing | &T.&T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1160:24:1160:39 | &... | | file://:0:0:0:0 | & |
|
||||
| main.rs:1160:24:1160:39 | &... | &T | file://:0:0:0:0 | & |
|
||||
| main.rs:1160:24:1160:39 | &... | &T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1160:24:1160:39 | &... | &T.&T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1160:25:1160:39 | MyInt {...} | | file://:0:0:0:0 | & |
|
||||
| main.rs:1160:25:1160:39 | MyInt {...} | | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1160:25:1160:39 | MyInt {...} | &T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1160:36:1160:37 | 37 | | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:1160:36:1160:37 | 37 | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1162:13:1162:13 | a | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1162:17:1162:24 | my_thing | | file://:0:0:0:0 | & |
|
||||
| main.rs:1162:17:1162:24 | my_thing | &T | file://:0:0:0:0 | & |
|
||||
| main.rs:1162:17:1162:24 | my_thing | &T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1162:17:1162:24 | my_thing | &T.&T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1162:17:1162:43 | my_thing.method_on_borrow() | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1163:18:1163:23 | "{:?}\\n" | | {EXTERNAL LOCATION} | str |
|
||||
| main.rs:1163:26:1163:26 | a | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1166:13:1166:20 | my_thing | | file://:0:0:0:0 | & |
|
||||
| main.rs:1166:13:1166:20 | my_thing | &T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1166:24:1166:39 | &... | | file://:0:0:0:0 | & |
|
||||
@@ -1749,9 +1766,12 @@ inferType
|
||||
| main.rs:1166:25:1166:39 | MyInt {...} | | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1166:36:1166:37 | 38 | | {EXTERNAL LOCATION} | i32 |
|
||||
| main.rs:1166:36:1166:37 | 38 | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1167:13:1167:13 | a | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1167:17:1167:24 | my_thing | | file://:0:0:0:0 | & |
|
||||
| main.rs:1167:17:1167:24 | my_thing | &T | main.rs:1082:5:1085:5 | MyInt |
|
||||
| main.rs:1167:17:1167:47 | my_thing.method_not_on_borrow() | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1168:18:1168:23 | "{:?}\\n" | | {EXTERNAL LOCATION} | str |
|
||||
| main.rs:1168:26:1168:26 | a | | {EXTERNAL LOCATION} | i64 |
|
||||
| main.rs:1175:16:1175:20 | SelfParam | | file://:0:0:0:0 | & |
|
||||
| main.rs:1175:16:1175:20 | SelfParam | &T | main.rs:1173:5:1181:5 | Self [trait MyTrait] |
|
||||
| main.rs:1178:16:1178:20 | SelfParam | | file://:0:0:0:0 | & |
|
||||
|
||||
Reference in New Issue
Block a user