- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.F-lint_reasons`#![feature(lint_reasons)]``#![feature(lint_reasons)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
#[must_use]
pub fn important() -> i32 {
    42
}
pub fn foo() {
    #[expect(unused_must_use)]
    important();
}I expected #[expect] to catch unused_must_use lint and suppress it, as it should. Instead, compiler issues a diagnostic both about unused #[must_use] value and unfulfilled lint expectation:
warning: unused return value of `important` that must be used
 --> src/lib.rs:8:5
  |
8 |     important();
  |     ^^^^^^^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
8 |     let _ = important();
  |     +++++++
warning: this lint expectation is unfulfilled
 --> src/lib.rs:7:14
  |
7 |     #[expect(unused_must_use)]
  |              ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default
It does work as expected though if #[expect] is applied to function.
Meta
I used the latest stable (Rust 1.81), but it is reproducible both on latest beta (2024-09-04 c7c49f4) and latest nightly (2024-09-05 9c01301).
@rustbot labels: +F-lint_reasons, +A-diagnostics
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.F-lint_reasons`#![feature(lint_reasons)]``#![feature(lint_reasons)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.