Closed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment