Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing unused_must_use for RPITIT #118444

Closed
lukas-code opened this issue Nov 29, 2023 · 0 comments · Fixed by #118504
Closed

missing unused_must_use for RPITIT #118444

lukas-code opened this issue Nov 29, 2023 · 0 comments · Fixed by #118504
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lukas-code
Copy link
Member

Code

pub trait Tr {
    fn foo() -> impl std::future::Future<Output = ()>;
}

pub async fn bar<T: Tr>() {
    T::foo();
}

Current output

nothing

Desired output

warning: unused implementer of `Future` that must be used
  --> src/lib.rs:10:5
   |
10 |     Tr::foo();
   |     ^^^^^^^^^
   |
   = note: futures do nothing unless you `.await` or poll them
   = note: `#[warn(unused_must_use)]` on by default

Rationale and extra context

No response

Other cases

applies to all #[must_use] traits that are used as RPITIT

Anything else?

No response

@lukas-code lukas-code added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 29, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 29, 2023
@compiler-errors compiler-errors self-assigned this Nov 29, 2023
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2023
@bors bors closed this as completed in 1b391d4 Dec 7, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 7, 2023
Rollup merge of rust-lang#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 rust-lang#118444
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants