Auto merge of #11802 - dswij:issue-11765, r=xFrednet
`needless_return_with_question_mark` ignore let-else Fixes #11765 This PR makes `needless_return_with_question_mark` to ignore expr inside let-else. changelog: [`needless_return_with_question_mark`] ignore let-else
This commit is contained in:
commit
7ad3373bb1
5 changed files with 84 additions and 2 deletions
|
|
@ -4,6 +4,7 @@
|
|||
clippy::no_effect,
|
||||
clippy::unit_arg,
|
||||
clippy::useless_conversion,
|
||||
clippy::diverging_sub_expression,
|
||||
unused
|
||||
)]
|
||||
|
||||
|
|
@ -35,5 +36,26 @@ fn main() -> Result<(), ()> {
|
|||
with_span! {
|
||||
return Err(())?;
|
||||
}
|
||||
|
||||
// Issue #11765
|
||||
// Should not lint
|
||||
let Some(s) = Some("") else {
|
||||
return Err(())?;
|
||||
};
|
||||
|
||||
let Some(s) = Some("") else {
|
||||
let Some(s) = Some("") else {
|
||||
return Err(())?;
|
||||
};
|
||||
|
||||
return Err(())?;
|
||||
};
|
||||
|
||||
let Some(_): Option<()> = ({
|
||||
return Err(())?;
|
||||
}) else {
|
||||
panic!();
|
||||
};
|
||||
|
||||
Err(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
clippy::no_effect,
|
||||
clippy::unit_arg,
|
||||
clippy::useless_conversion,
|
||||
clippy::diverging_sub_expression,
|
||||
unused
|
||||
)]
|
||||
|
||||
|
|
@ -35,5 +36,26 @@ fn main() -> Result<(), ()> {
|
|||
with_span! {
|
||||
return Err(())?;
|
||||
}
|
||||
|
||||
// Issue #11765
|
||||
// Should not lint
|
||||
let Some(s) = Some("") else {
|
||||
return Err(())?;
|
||||
};
|
||||
|
||||
let Some(s) = Some("") else {
|
||||
let Some(s) = Some("") else {
|
||||
return Err(())?;
|
||||
};
|
||||
|
||||
return Err(())?;
|
||||
};
|
||||
|
||||
let Some(_): Option<()> = ({
|
||||
return Err(())?;
|
||||
}) else {
|
||||
panic!();
|
||||
};
|
||||
|
||||
Err(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: unneeded `return` statement with `?` operator
|
||||
--> $DIR/needless_return_with_question_mark.rs:27:5
|
||||
--> $DIR/needless_return_with_question_mark.rs:28:5
|
||||
|
|
||||
LL | return Err(())?;
|
||||
| ^^^^^^^ help: remove it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue