-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #11627 - y21:issue11616, r=giraffate
[`needless_return_with_question_mark`]: don't lint if never type is used for coercion Fixes #11616 When we have something like ```rs let _x: String = { return Err(())?; }; ``` we shouldn't suggest removing the `return` because the `!`-ness of `return` is used to coerce the enclosing block to some other type. That will lead to a typeck error without a diverging expression like `return`. changelog: [`needless_return_with_question_mark`]: don't lint if `return`s never typed-ness is used for coercion
- Loading branch information
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
error: unneeded `return` statement with `?` operator | ||
--> $DIR/needless_return_with_question_mark.rs:28:5 | ||
--> $DIR/needless_return_with_question_mark.rs:29:5 | ||
| | ||
LL | return Err(())?; | ||
| ^^^^^^^ help: remove it | ||
| | ||
= note: `-D clippy::needless-return-with-question-mark` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::needless_return_with_question_mark)]` | ||
|
||
error: aborting due to previous error | ||
error: unneeded `return` statement with `?` operator | ||
--> $DIR/needless_return_with_question_mark.rs:69:9 | ||
| | ||
LL | return Err(())?; | ||
| ^^^^^^^ help: remove it | ||
|
||
error: aborting due to 2 previous errors | ||
|