Lint explicit_auto_deref in implicit return positions for closures

This commit is contained in:
Jason Newcomb
2022-08-08 10:25:05 -04:00
parent 5285928bc0
commit ecb51fe6a5
5 changed files with 42 additions and 20 deletions

View File

@@ -257,13 +257,13 @@ fn main() {
let x = S7([0]);
let _: &[u32] = &*x;
let c1 = |x: &Vec<&u32>| {};
let c1 = |_: &Vec<&u32>| {};
let x = &&vec![&1u32];
c1(x);
let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> {
if b {
return x;
}
*x
x
};
}

View File

@@ -257,7 +257,7 @@ fn main() {
let x = S7([0]);
let _: &[u32] = &*x;
let c1 = |x: &Vec<&u32>| {};
let c1 = |_: &Vec<&u32>| {};
let x = &&vec![&1u32];
c1(*x);
let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> {

View File

@@ -228,5 +228,11 @@ error: deref which would be done by auto-deref
LL | return *x;
| ^^ help: try this: `x`
error: aborting due to 38 previous errors
error: deref which would be done by auto-deref
--> $DIR/explicit_auto_deref.rs:267:9
|
LL | *x
| ^^ help: try this: `x`
error: aborting due to 39 previous errors