mirror of
https://github.com/github/codeql.git
synced 2026-02-12 05:01:06 +01:00
Rust: More type inference tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/// This file contains tests for dereferencing with through the `Deref` trait.
|
||||
use std::ops::Deref;
|
||||
use std::ops::DerefMut;
|
||||
|
||||
struct MyIntPointer {
|
||||
value: i64,
|
||||
@@ -27,6 +28,13 @@ impl<T> Deref for MySmartPointer<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> DerefMut for MySmartPointer<T> {
|
||||
// MySmartPointer::deref_mut
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
&mut self.value // $ fieldof=MySmartPointer
|
||||
}
|
||||
}
|
||||
|
||||
struct S<T>(T);
|
||||
|
||||
impl<T> S<T> {
|
||||
@@ -102,6 +110,10 @@ fn implicit_dereference() {
|
||||
|
||||
let z = MySmartPointer { value: S(0i64) };
|
||||
let z_ = z.foo(); // $ MISSING: target=foo type=z_:TRef.i64
|
||||
|
||||
let v = Vec::new(); // $ target=new $ MISSING: type=v:T.i32
|
||||
let mut x = MySmartPointer { value: v };
|
||||
x.push(0); // $ MISSING: target=push
|
||||
}
|
||||
|
||||
mod implicit_deref_coercion_cycle {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user