Skip to content

Commit f30a3b3

Browse files
committed
Rust: Add type inference blowup test
1 parent 000f2c3 commit f30a3b3

File tree

3 files changed

+345
-84
lines changed

3 files changed

+345
-84
lines changed

rust/ql/test/library-tests/type-inference/CONSISTENCY/PathResolutionConsistency.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ multipleResolvedTargets
3030
| main.rs:2642:13:2642:31 | ...::from(...) |
3131
| main.rs:2643:13:2643:31 | ...::from(...) |
3232
| main.rs:2644:13:2644:31 | ...::from(...) |
33+
| main.rs:3067:13:3067:17 | x.f() |
3334
| pattern_matching.rs:273:13:273:27 | * ... |
3435
| pattern_matching.rs:273:14:273:27 | * ... |

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,6 +3036,39 @@ mod context_typed {
30363036
}
30373037
}
30383038

3039+
mod literal_overlap {
3040+
trait MyTrait {
3041+
fn f(self) -> Self;
3042+
}
3043+
3044+
impl MyTrait for i32 {
3045+
// i32f
3046+
fn f(self) -> Self {
3047+
self
3048+
}
3049+
}
3050+
3051+
impl MyTrait for usize {
3052+
// usizef
3053+
fn f(self) -> Self {
3054+
self
3055+
}
3056+
}
3057+
3058+
impl<T> MyTrait for &T {
3059+
// Reff
3060+
fn f(self) -> Self {
3061+
self
3062+
}
3063+
}
3064+
3065+
pub fn f() -> usize {
3066+
let mut x = 0;
3067+
x = x.f(); // $ target=usizef $ SPURIOUS: target=i32f target=Reff
3068+
x
3069+
}
3070+
}
3071+
30393072
mod blanket_impl;
30403073
mod closure;
30413074
mod dereference;

0 commit comments

Comments
 (0)