-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 #61100 - varkor:must_use-tuple-expr, r=cramertj
Apply #[must_use] lint to components of tuples Fixes #61061.
- Loading branch information
Showing
3 changed files
with
136 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![deny(unused_must_use)] | ||
|
||
fn foo() -> (Result<(), ()>, ()) { | ||
(Ok::<(), ()>(()), ()) | ||
} | ||
|
||
fn main() { | ||
(Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` | ||
|
||
(Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); | ||
//~^ ERROR unused `std::result::Result` | ||
//~^^ ERROR unused `std::result::Result` | ||
|
||
foo(); //~ ERROR unused `std::result::Result` | ||
|
||
((Err::<(), ()>(()), ()), ()); //~ ERROR unused `std::result::Result` | ||
} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
error: unused `std::result::Result` in tuple element 0 that must be used | ||
--> $DIR/must_use-tuple.rs:8:6 | ||
| | ||
LL | (Ok::<(), ()>(()),); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/must_use-tuple.rs:1:9 | ||
| | ||
LL | #![deny(unused_must_use)] | ||
| ^^^^^^^^^^^^^^^ | ||
= note: this `Result` may be an `Err` variant, which should be handled | ||
|
||
error: unused `std::result::Result` in tuple element 0 that must be used | ||
--> $DIR/must_use-tuple.rs:10:6 | ||
| | ||
LL | (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this `Result` may be an `Err` variant, which should be handled | ||
|
||
error: unused `std::result::Result` in tuple element 2 that must be used | ||
--> $DIR/must_use-tuple.rs:10:27 | ||
| | ||
LL | (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this `Result` may be an `Err` variant, which should be handled | ||
|
||
error: unused `std::result::Result` in tuple element 0 that must be used | ||
--> $DIR/must_use-tuple.rs:14:5 | ||
| | ||
LL | foo(); | ||
| ^^^^^^ | ||
| | ||
= note: this `Result` may be an `Err` variant, which should be handled | ||
|
||
error: unused `std::result::Result` in tuple element 0 that must be used | ||
--> $DIR/must_use-tuple.rs:16:6 | ||
| | ||
LL | ((Err::<(), ()>(()), ()), ()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this `Result` may be an `Err` variant, which should be handled | ||
|
||
error: aborting due to 5 previous errors | ||
|