Avoid linting for closures with inferred return types
This commit is contained in:
parent
6205bcf0f1
commit
139bb25927
4 changed files with 26 additions and 6 deletions
|
|
@ -201,6 +201,16 @@ fn infer_check() {
|
|||
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let closure = |x: Result<u8, ()>| -> Result<(), _> {
|
||||
// `?` would fail here, as it expands to `Err(val.into())` which is not constrained.
|
||||
let _val = match x {
|
||||
Ok(val) => val,
|
||||
Err(val) => return Err(val),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
// see issue #8019
|
||||
|
|
|
|||
|
|
@ -248,6 +248,16 @@ fn infer_check() {
|
|||
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let closure = |x: Result<u8, ()>| -> Result<(), _> {
|
||||
// `?` would fail here, as it expands to `Err(val.into())` which is not constrained.
|
||||
let _val = match x {
|
||||
Ok(val) => val,
|
||||
Err(val) => return Err(val),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
// see issue #8019
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ LL | | };
|
|||
| |_____^ help: try instead: `func_returning_result()?`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> tests/ui/question_mark.rs:274:5
|
||||
--> tests/ui/question_mark.rs:284:5
|
||||
|
|
||||
LL | / if let Err(err) = func_returning_result() {
|
||||
LL | | return Err(err);
|
||||
|
|
@ -171,7 +171,7 @@ LL | | }
|
|||
| |_____^ help: replace it with: `func_returning_result()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> tests/ui/question_mark.rs:281:5
|
||||
--> tests/ui/question_mark.rs:291:5
|
||||
|
|
||||
LL | / if let Err(err) = func_returning_result() {
|
||||
LL | | return Err(err);
|
||||
|
|
@ -179,7 +179,7 @@ LL | | }
|
|||
| |_____^ help: replace it with: `func_returning_result()?;`
|
||||
|
||||
error: this block may be rewritten with the `?` operator
|
||||
--> tests/ui/question_mark.rs:358:13
|
||||
--> tests/ui/question_mark.rs:368:13
|
||||
|
|
||||
LL | / if a.is_none() {
|
||||
LL | | return None;
|
||||
|
|
@ -189,7 +189,7 @@ LL | | }
|
|||
| |_____________^ help: replace it with: `a?;`
|
||||
|
||||
error: this `let...else` may be rewritten with the `?` operator
|
||||
--> tests/ui/question_mark.rs:418:5
|
||||
--> tests/ui/question_mark.rs:428:5
|
||||
|
|
||||
LL | / let Some(v) = bar.foo.owned.clone() else {
|
||||
LL | | return None;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue