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

Compilation warning does not appear even if #[must_use] is used in a non-function. #93906

Closed
Danue1 opened this issue Feb 11, 2022 · 1 comment · Fixed by #93926
Closed

Compilation warning does not appear even if #[must_use] is used in a non-function. #93906

Danue1 opened this issue Feb 11, 2022 · 1 comment · Fixed by #93926
Assignees
Labels
C-bug Category: This is a bug.

Comments

@Danue1
Copy link
Contributor

Danue1 commented Feb 11, 2022

I tried this code:

fn main() {
    #[must_use]
    {}
}

I expected to see this happen: Warning that it is unused.

Instead, this happened: Not warning.

Meta

rustc --version --verbose:

rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: aarch64-apple-darwin
release: 1.58.1
LLVM version: 13.0.0
@Danue1 Danue1 added the C-bug Category: This is a bug. label Feb 11, 2022
@PatchMixolydic
Copy link
Contributor

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 1, 2022
…xprs, r=cjgillot

Lint against more useless `#[must_use]` attributes

This expands the existing `#[must_use]` check in `unused_attributes` to lint against pretty much everything `#[must_use]` doesn't support.
Fixes rust-lang#93906.
@bors bors closed this as completed in 6dcf5d8 Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants