-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #118504 - compiler-errors:must-use, r=WaffleLapkin
Enforce `must_use` on associated types and RPITITs that have a must-use trait in bounds Warn when an RPITIT or (un-normalized) associated type with a `#[must_use]` trait in its bounds is unused. This is pending T-lang approval, since it changes the semantics of the `#[must_use]` attribute slightly, but I think it strictly catches more strange errors. I could also limit this to just RPITITs, but that seems less useful. Fixes #118444
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
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,15 @@ | ||
error: unused implementer of `Future` that must be used | ||
--> $DIR/assoc-types.rs:19:5 | ||
| | ||
LL | T::foo(); | ||
| ^^^^^^^^ | ||
| | ||
= note: futures do nothing unless you `.await` or poll them | ||
note: the lint level is defined here | ||
--> $DIR/assoc-types.rs:4:9 | ||
| | ||
LL | #![deny(unused_must_use)] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
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,15 @@ | ||
error: unused implementer of `Future` that must be used | ||
--> $DIR/assoc-types.rs:19:5 | ||
| | ||
LL | T::foo(); | ||
| ^^^^^^^^ | ||
| | ||
= note: futures do nothing unless you `.await` or poll them | ||
note: the lint level is defined here | ||
--> $DIR/assoc-types.rs:4:9 | ||
| | ||
LL | #![deny(unused_must_use)] | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
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,23 @@ | ||
// edition: 2021 | ||
// revisions: rpitit assoc_ty | ||
|
||
#![deny(unused_must_use)] | ||
|
||
use std::future::Future; | ||
|
||
pub trait Tr { | ||
type Fut: Future<Output = ()>; | ||
|
||
#[cfg(rpitit)] | ||
fn foo() -> impl Future<Output = ()>; | ||
|
||
#[cfg(assoc_ty)] | ||
fn foo() -> Self::Fut; | ||
} | ||
|
||
pub async fn bar<T: Tr>() { | ||
T::foo(); | ||
//~^ ERROR unused implementer of `Future` that must be used | ||
} | ||
|
||
fn main() {} |