mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Address review comments
This commit is contained in:
@@ -29,7 +29,11 @@ abstract class FieldContent extends Content {
|
||||
class TupleFieldContent extends FieldContent, TTupleFieldContent {
|
||||
private TupleField field;
|
||||
|
||||
TupleFieldContent() { this = TTupleFieldContent(field) }
|
||||
TupleFieldContent() {
|
||||
this = TTupleFieldContent(field) and
|
||||
// tuples are handled using the special `TupleContent` type
|
||||
not field = any(TupleType tt).getATupleField()
|
||||
}
|
||||
|
||||
/** Holds if this field belongs to an enum variant. */
|
||||
predicate isVariantField(Variant v, int pos) { field.isVariantField(v, pos) }
|
||||
@@ -37,11 +41,7 @@ class TupleFieldContent extends FieldContent, TTupleFieldContent {
|
||||
/** Holds if this field belongs to a struct. */
|
||||
predicate isStructField(Struct s, int pos) { field.isStructField(s, pos) }
|
||||
|
||||
override FieldExprCfgNode getAnAccess() {
|
||||
field = result.getFieldExpr().getTupleField() and
|
||||
// tuples are handled using the special `TupleContent` type
|
||||
not field = any(TupleType tt).getATupleField()
|
||||
}
|
||||
override FieldExprCfgNode getAnAccess() { field = result.getFieldExpr().getTupleField() }
|
||||
|
||||
final override string toString() {
|
||||
exists(Variant v, int pos, string vname |
|
||||
|
||||
@@ -2172,8 +2172,7 @@ private predicate builtin(string name, ItemNode i) {
|
||||
exists(BuiltinSourceFile builtins |
|
||||
builtins.getFile().getBaseName() = "types.rs" and
|
||||
i = builtins.getASuccessor(name) and
|
||||
not name = ["Slice", "Array", "Ref", "Ptr"] and
|
||||
not name.matches("Tuple%")
|
||||
i.isPublic()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +208,7 @@ class UnionType extends Type, TUnion {
|
||||
/**
|
||||
* An array type.
|
||||
*
|
||||
* Array types like `[i64; 5]` are modeled as normal generic types
|
||||
* with a single type argument.
|
||||
* Array types like `[i64; 5]` are modeled as normal generic types.
|
||||
*/
|
||||
class ArrayType extends StructType {
|
||||
ArrayType() { this.getStruct() instanceof Builtins::ArrayType }
|
||||
@@ -401,32 +400,7 @@ class TypeParamTypeParameter extends TypeParameter, TTypeParamTypeParameter {
|
||||
|
||||
TypeParam getTypeParam() { result = typeParam }
|
||||
|
||||
override string toString() {
|
||||
this = any(SliceType st).getATypeParameter() and
|
||||
result = "[T]"
|
||||
or
|
||||
this = any(ArrayType at).getATypeParameter() and
|
||||
result = "[T;...]"
|
||||
or
|
||||
this = any(RefType rt).getATypeParameter() and
|
||||
result = "&T"
|
||||
or
|
||||
this = any(PtrType pt).getATypeParameter() and
|
||||
result = "*T"
|
||||
or
|
||||
exists(TupleType tt, int arity, int i |
|
||||
this = tt.getPositionalTypeParameter(i) and
|
||||
arity = tt.getArity() and
|
||||
result = i + "(" + arity + ")"
|
||||
)
|
||||
or
|
||||
not this = any(SliceType st).getATypeParameter() and
|
||||
not this = any(ArrayType at).getATypeParameter() and
|
||||
not this = any(RefType rt).getATypeParameter() and
|
||||
not this = any(PtrType pt).getATypeParameter() and
|
||||
not this = any(TupleType tt).getATypeParameter() and
|
||||
result = typeParam.toString()
|
||||
}
|
||||
override string toString() { result = typeParam.toString() }
|
||||
|
||||
override Location getLocation() { result = typeParam.getLocation() }
|
||||
}
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
| struct Tuple10 | |
|
||||
| struct Tuple11 | |
|
||||
| struct Tuple12 | |
|
||||
| struct Tuple13 | |
|
||||
| struct Tuple14 | |
|
||||
| struct Tuple15 | |
|
||||
| struct Tuple16 | |
|
||||
| struct bool | |
|
||||
| struct char | |
|
||||
| struct f32 | FloatingPointType, NumericType |
|
||||
|
||||
@@ -38,7 +38,7 @@ impl<T> S<T> {
|
||||
fn explicit_monomorphic_dereference() {
|
||||
// Dereference with method call
|
||||
let a1 = MyIntPointer { value: 34i64 };
|
||||
let _b1 = a1.deref(); // $ target=MyIntPointer::deref type=_b1:&T.i64
|
||||
let _b1 = a1.deref(); // $ target=MyIntPointer::deref type=_b1:TRef.i64
|
||||
|
||||
// Dereference with overloaded dereference operator
|
||||
let a2 = MyIntPointer { value: 34i64 };
|
||||
@@ -52,7 +52,7 @@ fn explicit_monomorphic_dereference() {
|
||||
fn explicit_polymorphic_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let c1 = MySmartPointer { value: 'a' };
|
||||
let _d1 = c1.deref(); // $ target=MySmartPointer::deref type=_d1:&T.char
|
||||
let _d1 = c1.deref(); // $ target=MySmartPointer::deref type=_d1:TRef.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let c2 = MySmartPointer { value: 'a' };
|
||||
@@ -66,7 +66,7 @@ fn explicit_polymorphic_dereference() {
|
||||
fn explicit_ref_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let e1 = &'a';
|
||||
let _f1 = e1.deref(); // $ target=deref type=_f1:&T.char
|
||||
let _f1 = e1.deref(); // $ target=deref type=_f1:TRef.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let e2 = &'a';
|
||||
@@ -80,7 +80,7 @@ fn explicit_ref_dereference() {
|
||||
fn explicit_box_dereference() {
|
||||
// Explicit dereference with type parameter
|
||||
let g1: Box<char> = Box::new('a'); // $ target=new
|
||||
let _h1 = g1.deref(); // $ target=deref type=_h1:&T.char
|
||||
let _h1 = g1.deref(); // $ target=deref type=_h1:TRef.char
|
||||
|
||||
// Explicit dereference with type parameter
|
||||
let g2: Box<char> = Box::new('a'); // $ target=new
|
||||
@@ -101,7 +101,7 @@ fn implicit_dereference() {
|
||||
let _y = x.is_positive(); // $ MISSING: target=is_positive type=_y:bool
|
||||
|
||||
let z = MySmartPointer { value: S(0i64) };
|
||||
let z_ = z.foo(); // $ MISSING: target=foo type=z_:&T.i64
|
||||
let z_ = z.foo(); // $ MISSING: target=foo type=z_:TRef.i64
|
||||
}
|
||||
|
||||
mod implicit_deref_coercion_cycle {
|
||||
|
||||
@@ -1542,7 +1542,7 @@ mod method_call_type_conversion {
|
||||
let x7 = S(&S2);
|
||||
// Non-implicit dereference with nested borrow in order to test that the
|
||||
// implicit dereference handling doesn't affect nested borrows.
|
||||
let t = x7.m1(); // $ target=m1 type=t:& type=t:&T.S2
|
||||
let t = x7.m1(); // $ target=m1 type=t:& type=t:TRef.S2
|
||||
println!("{:?}", x7);
|
||||
|
||||
let x9: String = "Hello".to_string(); // $ certainType=x9:String target=to_string
|
||||
@@ -1732,7 +1732,7 @@ mod builtins {
|
||||
let z = x + y; // $ type=z:i32 target=add
|
||||
let z = x.abs(); // $ target=abs $ type=z:i32
|
||||
let c = 'c'; // $ certainType=c:char
|
||||
let hello = "Hello"; // $ certainType=hello:&T.str
|
||||
let hello = "Hello"; // $ certainType=hello:TRef.str
|
||||
let f = 123.0f64; // $ certainType=f:f64
|
||||
let t = true; // $ certainType=t:bool
|
||||
let f = false; // $ certainType=f:bool
|
||||
@@ -1753,8 +1753,8 @@ mod builtins {
|
||||
}
|
||||
}
|
||||
|
||||
let x = [1, 2, 3].my_method(); // $ target=my_method type=x:&T.i32
|
||||
let x = <[_; 3]>::my_method(&[1, 2, 3]); // $ target=my_method type=x:&T.i32
|
||||
let x = [1, 2, 3].my_method(); // $ target=my_method type=x:TRef.i32
|
||||
let x = <[_; 3]>::my_method(&[1, 2, 3]); // $ target=my_method type=x:TRef.i32
|
||||
let x = <[i32; 3]>::my_func(); // $ target=my_func type=x:i32
|
||||
|
||||
impl<T: Default> MyTrait<T> for [T] {
|
||||
@@ -1768,8 +1768,8 @@ mod builtins {
|
||||
}
|
||||
|
||||
let s: &[i32] = &[1, 2, 3];
|
||||
let x = s.my_method(); // $ target=my_method type=x:&T.i32
|
||||
let x = <[_]>::my_method(s); // $ target=my_method type=x:&T.i32
|
||||
let x = s.my_method(); // $ target=my_method type=x:TRef.i32
|
||||
let x = <[_]>::my_method(s); // $ target=my_method type=x:TRef.i32
|
||||
let x = <[i32]>::my_func(); // $ target=my_func type=x:i32
|
||||
|
||||
impl<T: Default> MyTrait<T> for (T, i32) {
|
||||
@@ -1783,8 +1783,8 @@ mod builtins {
|
||||
}
|
||||
|
||||
let p = (42, 7);
|
||||
let x = p.my_method(); // $ target=my_method type=x:&T.i32
|
||||
let x = <(_, _)>::my_method(&p); // $ target=my_method type=x:&T.i32
|
||||
let x = p.my_method(); // $ target=my_method type=x:TRef.i32
|
||||
let x = <(_, _)>::my_method(&p); // $ target=my_method type=x:TRef.i32
|
||||
let x = <(i32, i32)>::my_func(); // $ target=my_func type=x:i32
|
||||
|
||||
impl<T: Default> MyTrait<T> for &T {
|
||||
@@ -1798,8 +1798,8 @@ mod builtins {
|
||||
}
|
||||
|
||||
let r = &42;
|
||||
let x = r.my_method(); // $ target=my_method type=x:&T.i32
|
||||
let x = <&_>::my_method(&r); // $ target=my_method type=x:&T.i32
|
||||
let x = r.my_method(); // $ target=my_method type=x:TRef.i32
|
||||
let x = <&_>::my_method(&r); // $ target=my_method type=x:TRef.i32
|
||||
let x = <&i32>::my_func(); // $ target=my_func type=x:i32
|
||||
|
||||
impl<T: Default> MyTrait<T> for *mut T {
|
||||
@@ -1814,8 +1814,8 @@ mod builtins {
|
||||
|
||||
let mut v = 42;
|
||||
let p: *mut i32 = &mut v;
|
||||
let x = unsafe { p.my_method() }; // $ target=my_method type=x:&T.i32
|
||||
let x = unsafe { <*mut _>::my_method(&p) }; // $ target=my_method type=x:&T.i32
|
||||
let x = unsafe { p.my_method() }; // $ target=my_method type=x:TRef.i32
|
||||
let x = unsafe { <*mut _>::my_method(&p) }; // $ target=my_method type=x:TRef.i32
|
||||
let x = <*mut i32>::my_func(); // $ target=my_func type=x:i32
|
||||
}
|
||||
}
|
||||
@@ -2612,24 +2612,24 @@ mod loops {
|
||||
for i in [1, 2, 3].map(|x| x + 1) {} // $ target=map MISSING: type=i:i32
|
||||
for i in [1, 2, 3].into_iter() {} // $ target=into_iter type=i:i32
|
||||
|
||||
let vals1 = [1u8, 2, 3]; // $ type=vals1:[T;...].u8
|
||||
let vals1 = [1u8, 2, 3]; // $ type=vals1:TArray.u8
|
||||
for u in vals1 {} // $ type=u:u8
|
||||
|
||||
let vals2 = [1u16; 3]; // $ type=vals2:[T;...].u16
|
||||
let vals2 = [1u16; 3]; // $ type=vals2:TArray.u16
|
||||
for u in vals2 {} // $ type=u:u16
|
||||
|
||||
let vals3: [u32; 3] = [1, 2, 3]; // $ certainType=vals3:[T;...].u32
|
||||
let vals3: [u32; 3] = [1, 2, 3]; // $ certainType=vals3:TArray.u32
|
||||
for u in vals3 {} // $ type=u:u32
|
||||
|
||||
let vals4: [u64; 3] = [1; 3]; // $ certainType=vals4:[T;...].u64
|
||||
let vals4: [u64; 3] = [1; 3]; // $ certainType=vals4:TArray.u64
|
||||
for u in vals4 {} // $ type=u:u64
|
||||
|
||||
let mut strings1 = ["foo", "bar", "baz"]; // $ type=strings1:[T;...].&T.str
|
||||
for s in &strings1 {} // $ type=s:&T.&T.str
|
||||
for s in &mut strings1 {} // $ type=s:&T.&T.str
|
||||
for s in strings1 {} // $ type=s:&T.str
|
||||
let mut strings1 = ["foo", "bar", "baz"]; // $ type=strings1:TArray.TRef.str
|
||||
for s in &strings1 {} // $ type=s:TRef.TRef.str
|
||||
for s in &mut strings1 {} // $ type=s:TRef.TRef.str
|
||||
for s in strings1 {} // $ type=s:TRef.str
|
||||
|
||||
let strings2 = // $ type=strings2:[T;...].String
|
||||
let strings2 = // $ type=strings2:TArray.String
|
||||
[
|
||||
String::from("foo"), // $ target=from
|
||||
String::from("bar"), // $ target=from
|
||||
@@ -2637,15 +2637,15 @@ mod loops {
|
||||
];
|
||||
for s in strings2 {} // $ type=s:String
|
||||
|
||||
let strings3 = // $ type=strings3:&T.[T;...].String
|
||||
let strings3 = // $ type=strings3:TRef.TArray.String
|
||||
&[
|
||||
String::from("foo"), // $ target=from
|
||||
String::from("bar"), // $ target=from
|
||||
String::from("baz"), // $ target=from
|
||||
];
|
||||
for s in strings3 {} // $ type=s:&T.String
|
||||
for s in strings3 {} // $ type=s:TRef.String
|
||||
|
||||
let callables = [MyCallable::new(), MyCallable::new(), MyCallable::new()]; // $ target=new $ type=callables:[T;...].MyCallable
|
||||
let callables = [MyCallable::new(), MyCallable::new(), MyCallable::new()]; // $ target=new $ type=callables:TArray.MyCallable
|
||||
for c // $ type=c:MyCallable
|
||||
in callables
|
||||
{
|
||||
@@ -2659,7 +2659,7 @@ mod loops {
|
||||
let range = 0..10; // $ certainType=range:Range type=range:Idx.i32
|
||||
for i in range {} // $ type=i:i32
|
||||
let range_full = ..; // $ certainType=range_full:RangeFull
|
||||
for i in &[1i64, 2i64, 3i64][range_full] {} // $ target=index MISSING: type=i:&T.i64
|
||||
for i in &[1i64, 2i64, 3i64][range_full] {} // $ target=index MISSING: type=i:TRef.i64
|
||||
|
||||
let range1 = // $ certainType=range1:Range type=range1:Idx.u16
|
||||
std::ops::Range {
|
||||
@@ -2682,8 +2682,8 @@ mod loops {
|
||||
let vals5 = Vec::from([1u32, 2, 3]); // $ certainType=vals5:Vec target=from type=vals5:T.u32
|
||||
for u in vals5 {} // $ type=u:u32
|
||||
|
||||
let vals6: Vec<&u64> = [1u64, 2, 3].iter().collect(); // $ certainType=vals6:Vec certainType=vals6:T.&T.u64
|
||||
for u in vals6 {} // $ type=u:&T.u64
|
||||
let vals6: Vec<&u64> = [1u64, 2, 3].iter().collect(); // $ certainType=vals6:Vec certainType=vals6:T.TRef.u64
|
||||
for u in vals6 {} // $ type=u:TRef.u64
|
||||
|
||||
let mut vals7 = Vec::new(); // $ target=new certainType=vals7:Vec type=vals7:T.u8
|
||||
vals7.push(1u8); // $ target=push
|
||||
@@ -2696,13 +2696,13 @@ mod loops {
|
||||
}
|
||||
};
|
||||
|
||||
let mut map1 = std::collections::HashMap::new(); // $ target=new type=map1:K.i32 type=map1:V.Box $ MISSING: type=map1:Hashmap type1=map1:V.T.&T.str
|
||||
let mut map1 = std::collections::HashMap::new(); // $ target=new type=map1:K.i32 type=map1:V.Box $ MISSING: type=map1:Hashmap type1=map1:V.T.TRef.str
|
||||
map1.insert(1, Box::new("one")); // $ target=insert target=new
|
||||
map1.insert(2, Box::new("two")); // $ target=insert target=new
|
||||
for key in map1.keys() {} // $ target=keys type=key:&T.i32
|
||||
for value in map1.values() {} // $ target=values type=value:&T.Box type=value:&T.T.&T.str
|
||||
for (key, value) in map1.iter() {} // $ target=iter type=key:&T.i32 type=value:&T.Box type=value:&T.T.&T.str
|
||||
for (key, value) in &map1 {} // $ type=key:&T.i32 type=value:&T.Box type=value:&T.T.&T.str
|
||||
for key in map1.keys() {} // $ target=keys type=key:TRef.i32
|
||||
for value in map1.values() {} // $ target=values type=value:TRef.Box type=value:TRef.T.TRef.str
|
||||
for (key, value) in map1.iter() {} // $ target=iter type=key:TRef.i32 type=value:TRef.Box type=value:TRef.T.TRef.str
|
||||
for (key, value) in &map1 {} // $ type=key:TRef.i32 type=value:TRef.Box type=value:TRef.T.TRef.str
|
||||
|
||||
// while loops
|
||||
|
||||
@@ -2804,11 +2804,11 @@ mod tuples {
|
||||
// `a` and `b` to be inferred.
|
||||
let a = Default::default(); // $ target=default type=a:i64
|
||||
let b = Default::default(); // $ target=default type=b:bool
|
||||
let pair = (a, b); // $ type=pair:0(2).i64 type=pair:1(2).bool
|
||||
let pair = (a, b); // $ type=pair:T0.i64 type=pair:T1.bool
|
||||
let i: i64 = pair.0; // $ fieldof=Tuple2
|
||||
let j: bool = pair.1; // $ fieldof=Tuple2
|
||||
|
||||
let pair = [1, 1].into(); // $ type=pair:(T_2) type=pair:0(2).i32 type=pair:1(2).i32 MISSING: target=into
|
||||
let pair = [1, 1].into(); // $ type=pair:(T_2) type=pair:T0.i32 type=pair:T1.i32 MISSING: target=into
|
||||
match pair {
|
||||
(0, 0) => print!("unexpected"),
|
||||
_ => print!("expected"),
|
||||
|
||||
@@ -37,18 +37,18 @@ pub fn f() -> Option<()> {
|
||||
|
||||
let value3 = 42;
|
||||
if let ref mesg = value3 {
|
||||
let mesg = mesg; // $ type=mesg:&T.i32
|
||||
let mesg = mesg; // $ type=mesg:TRef.i32
|
||||
println!("{mesg}");
|
||||
}
|
||||
|
||||
let value4 = Some(42);
|
||||
if let Some(ref mesg) = value4 {
|
||||
let mesg = mesg; // $ type=mesg:&T.i32
|
||||
let mesg = mesg; // $ type=mesg:TRef.i32
|
||||
println!("{mesg}");
|
||||
}
|
||||
|
||||
let ref value5 = 42;
|
||||
let x = value5; // $ type=x:&T.i32
|
||||
let x = value5; // $ type=x:TRef.i32
|
||||
|
||||
let my_record_struct = MyRecordStruct {
|
||||
value1: 42,
|
||||
@@ -102,7 +102,7 @@ pub fn f() -> Option<()> {
|
||||
) => {
|
||||
let a = value1; // $ type=a:bool
|
||||
let b = x; // $ type=b:i32
|
||||
let c = y; // $ type=c:&T.str
|
||||
let c = y; // $ type=c:TRef.str
|
||||
();
|
||||
}
|
||||
_ => (),
|
||||
@@ -197,7 +197,7 @@ pub fn literal_patterns() {
|
||||
let string_val = "hello";
|
||||
match string_val {
|
||||
"hello" => {
|
||||
let hello_match = string_val; // $ certainType=hello_match:&T.str
|
||||
let hello_match = string_val; // $ certainType=hello_match:TRef.str
|
||||
println!("String literal: {}", hello_match);
|
||||
}
|
||||
_ => {}
|
||||
@@ -230,7 +230,7 @@ pub fn identifier_patterns() {
|
||||
// IdentPat with ref
|
||||
match &value {
|
||||
ref x => {
|
||||
let ref_bound = x; // $ type=ref_bound:&T.&T.i32
|
||||
let ref_bound = x; // $ type=ref_bound:TRef.TRef.i32
|
||||
println!("Reference identifier: {:?}", ref_bound);
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,7 @@ pub fn identifier_patterns() {
|
||||
let mut ref_mut_val = 5i32;
|
||||
match &mut ref_mut_val {
|
||||
ref mut x => {
|
||||
let ref_mut_bound = x; // $ type=ref_mut_bound:&T.&T.i32
|
||||
let ref_mut_bound = x; // $ type=ref_mut_bound:TRef.TRef.i32
|
||||
**ref_mut_bound += 1; // $ target=deref target=add_assign
|
||||
println!("Ref mut pattern");
|
||||
}
|
||||
@@ -341,14 +341,14 @@ pub fn reference_patterns() {
|
||||
|
||||
match &mut mutable_value {
|
||||
&mut ref x => {
|
||||
let mut_ref_bound = x; // $ type=mut_ref_bound:&T.i32
|
||||
let mut_ref_bound = x; // $ type=mut_ref_bound:TRef.i32
|
||||
println!("Mutable ref pattern: {}", mut_ref_bound);
|
||||
}
|
||||
}
|
||||
|
||||
match &value {
|
||||
ref x => {
|
||||
let ref_pattern = x; // $ type=ref_pattern:&T.&T.i32
|
||||
let ref_pattern = x; // $ type=ref_pattern:TRef.TRef.i32
|
||||
println!("Reference pattern: {}", ref_pattern);
|
||||
}
|
||||
}
|
||||
@@ -525,7 +525,7 @@ pub fn slice_patterns() {
|
||||
// SlicePat - Slice patterns
|
||||
match slice {
|
||||
[] => {
|
||||
let empty_slice = slice; // $ certainType=empty_slice:&T.[T].i32
|
||||
let empty_slice = slice; // $ certainType=empty_slice:TRef.TSlice.i32
|
||||
println!("Empty slice: {:?}", empty_slice);
|
||||
}
|
||||
[x] => {
|
||||
@@ -540,7 +540,7 @@ pub fn slice_patterns() {
|
||||
[first, middle @ .., last] => {
|
||||
let slice_start = *first; // $ MISSING: type=slice_start:i32
|
||||
let slice_end = *last; // $ MISSING: type=slice_end:i32
|
||||
let slice_middle = middle; // $ MISSING: type=slice_middle:&T.[T].i32
|
||||
let slice_middle = middle; // $ MISSING: type=slice_middle:TRef.TSlice.i32
|
||||
println!(
|
||||
"First: {}, last: {}, middle len: {}",
|
||||
slice_start,
|
||||
@@ -717,7 +717,7 @@ pub fn complex_nested_patterns() {
|
||||
}
|
||||
// Catch-all with identifier pattern
|
||||
other => {
|
||||
let other_complex = other; // $ type=other_complex:0(2).Point type=other_complex:1(2).MyOption
|
||||
let other_complex = other; // $ type=other_complex:T0.Point type=other_complex:T1.MyOption
|
||||
println!("Other complex data: {:?}", other_complex);
|
||||
}
|
||||
}
|
||||
@@ -750,7 +750,7 @@ pub fn patterns_in_let_statements() {
|
||||
// Let with reference pattern
|
||||
let value = 42i32;
|
||||
let ref ref_val = value;
|
||||
let let_ref = ref_val; // $ certainType=let_ref:&T.i32
|
||||
let let_ref = ref_val; // $ certainType=let_ref:TRef.i32
|
||||
|
||||
// Let with mutable pattern
|
||||
let mut mut_val = 10i32;
|
||||
@@ -779,13 +779,13 @@ pub fn patterns_in_function_parameters() {
|
||||
|
||||
// Call the functions to use them
|
||||
let point = Point { x: 5, y: 10 };
|
||||
let extracted = extract_point(point); // $ target=extract_point certainType=extracted:0(2).i32 certainType=extracted:1(2).i32
|
||||
let extracted = extract_point(point); // $ target=extract_point certainType=extracted:T0.i32 certainType=extracted:T1.i32
|
||||
|
||||
let color = Color(200, 100, 50);
|
||||
let red = extract_color(color); // $ target=extract_color certainType=red:u8
|
||||
|
||||
let tuple = (42i32, 3.14f64, true);
|
||||
let tuple_extracted = extract_tuple(tuple); // $ target=extract_tuple certainType=tuple_extracted:0(2).i32 certainType=tuple_extracted:1(2).bool
|
||||
let tuple_extracted = extract_tuple(tuple); // $ target=extract_tuple certainType=tuple_extracted:T0.i32 certainType=tuple_extracted:T1.bool
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,23 +24,25 @@ pub struct isize;
|
||||
pub struct f32;
|
||||
pub struct f64;
|
||||
|
||||
pub struct Slice<T>;
|
||||
pub struct Array<T, const N: usize>;
|
||||
pub struct Ref<T>; // todo: add mut variant
|
||||
pub struct Ptr<T>; // todo: add mut variant
|
||||
struct Slice<TSlice>;
|
||||
struct Array<TArray, const N: usize>;
|
||||
struct Ref<TRef>; // todo: add mut variant
|
||||
struct Ptr<TPtr>; // todo: add mut variant
|
||||
|
||||
// tuples
|
||||
pub struct Tuple0;
|
||||
pub struct Tuple1<T>(T);
|
||||
pub struct Tuple2<T1, T2>(T1, T2);
|
||||
pub struct Tuple3<T1, T2, T3>(T1, T2, T3);
|
||||
pub struct Tuple4<T1, T2, T3, T4>(T1, T2, T3, T4);
|
||||
pub struct Tuple5<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5);
|
||||
pub struct Tuple6<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6);
|
||||
pub struct Tuple7<T1, T2, T3, T4, T5, T6, T7>(T1, T2, T3, T4, T5, T6, T7);
|
||||
pub struct Tuple8<T1, T2, T3, T4, T5, T6, T7, T8>(T1, T2, T3, T4, T5, T6, T7, T8);
|
||||
pub struct Tuple9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(T1, T2, T3, T4, T5, T6, T7, T8, T9);
|
||||
pub struct Tuple10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
|
||||
struct Tuple0;
|
||||
struct Tuple1<T0>(T0);
|
||||
struct Tuple2<T0, T1>(T0, T1);
|
||||
struct Tuple3<T0, T1, T2>(T0, T1, T2);
|
||||
struct Tuple4<T0, T1, T2, T3>(T0, T1, T2, T3);
|
||||
struct Tuple5<T0, T1, T2, T3, T4>(T0, T1, T2, T3, T4);
|
||||
struct Tuple6<T0, T1, T2, T3, T4, T5>(T0, T1, T2, T3, T4, T5);
|
||||
struct Tuple7<T0, T1, T2, T3, T4, T5, T6>(T0, T1, T2, T3, T4, T5, T6);
|
||||
struct Tuple8<T0, T1, T2, T3, T4, T5, T6, T7>(T0, T1, T2, T3, T4, T5, T6, T7);
|
||||
struct Tuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>(T0, T1, T2, T3, T4, T5, T6, T7, T8);
|
||||
struct Tuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9);
|
||||
struct Tuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
|
||||
T0,
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
@@ -52,7 +54,8 @@ pub struct Tuple10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
|
||||
T9,
|
||||
T10,
|
||||
);
|
||||
pub struct Tuple11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
|
||||
struct Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
|
||||
T0,
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
@@ -65,83 +68,3 @@ pub struct Tuple11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
|
||||
T10,
|
||||
T11,
|
||||
);
|
||||
pub struct Tuple12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
T4,
|
||||
T5,
|
||||
T6,
|
||||
T7,
|
||||
T8,
|
||||
T9,
|
||||
T10,
|
||||
T11,
|
||||
T12,
|
||||
);
|
||||
pub struct Tuple13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
T4,
|
||||
T5,
|
||||
T6,
|
||||
T7,
|
||||
T8,
|
||||
T9,
|
||||
T10,
|
||||
T11,
|
||||
T12,
|
||||
T13,
|
||||
);
|
||||
pub struct Tuple14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
T4,
|
||||
T5,
|
||||
T6,
|
||||
T7,
|
||||
T8,
|
||||
T9,
|
||||
T10,
|
||||
T11,
|
||||
T12,
|
||||
T13,
|
||||
T14,
|
||||
);
|
||||
pub struct Tuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
T4,
|
||||
T5,
|
||||
T6,
|
||||
T7,
|
||||
T8,
|
||||
T9,
|
||||
T10,
|
||||
T11,
|
||||
T12,
|
||||
T13,
|
||||
T14,
|
||||
T15,
|
||||
);
|
||||
pub struct Tuple16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
|
||||
T1,
|
||||
T2,
|
||||
T3,
|
||||
T4,
|
||||
T5,
|
||||
T6,
|
||||
T7,
|
||||
T8,
|
||||
T9,
|
||||
T10,
|
||||
T11,
|
||||
T12,
|
||||
T13,
|
||||
T14,
|
||||
T15,
|
||||
T16,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user