-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
When a statement (macro?) triggers two different warnings and one of them is allow
-ed, the allow-ed warning triggers anyway
Lint Name
No response
Reproducer
I tried this code:
#[allow(clippy::write_with_newline)]
write!(w, "{}\n", val);
I saw this happen:
warning: unused attribute `allow`
--> src/lib.rs:9:5
|
9 | #[allow(clippy::write_with_newline)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the built-in attribute `allow` will be ignored, since it's applied to the macro invocation `write`
--> src/lib.rs:10:5
|
10 | write!(w, "{}\n", val);
| ^^^^^
= note: `#[warn(unused_attributes)]` on by default
warning: using `write!()` with a format string that ends in a single newline
--> src/lib.rs:10:5
|
10 | write!(w, "{}\n", val);
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#write_with_newline
= note: `#[warn(clippy::write_with_newline)]` on by default
help: use `writeln!` instead
|
10 - write!(w, "{}\n", val);
10 + writeln!(w, "{}", val);
|
warning: unused `std::result::Result` that must be used
--> src/lib.rs:10:5
|
10 | write!(w, "{}\n", val);
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
= note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
I expected to see this happen:
warning: unused `std::result::Result` that must be used
--> src/lib.rs:10:5
|
10 | write!(w, "{}\n", val);
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
= note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
The version which does not trigger unused_must_use
:
#[allow(clippy::write_with_newline)]
write!(w, "{}\n", val).unwrap();
does not trigger any warning
Version
rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: x86_64-unknown-linux-gnu
release: 1.67.0
LLVM version: 15.0.6
Also current playground
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have