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

[1.84.0 regression] #[allow(clippy::disallowed_macros)] does not work on two-argument std::panic #14017

Open
Deewiant opened this issue Jan 17, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Deewiant
Copy link

Summary

As of 1.84.0, it is not possible to use #[allow] or #[expect] to silence clippy::disallowed_macros when invoking std::panic with exactly two arguments.

Or at least, the straightforward thing does not work, and I haven't found a workaround other than "don't use std::panic with two arguments".

As far as I can tell, this is specific to std::panic and specific to the two-argument case, which seems pretty strange... But I obviously haven't exhaustively tested all macros so maybe that is just a coincidence.

Lint Name

disallowed_macros

Reproducer

I tried this code:

pub fn print_1_arg() {
    #![expect(clippy::disallowed_macros)]
    print!("foo");
}
pub fn print_2_args() {
    #![expect(clippy::disallowed_macros)]
    print!("{}", 123);
}
pub fn print_3_args() {
    #![expect(clippy::disallowed_macros)]
    print!("{} {}", 123, 456);
}

pub fn panic_1_arg() {
    #![expect(clippy::disallowed_macros)]
    panic!("foo");
}
pub fn panic_2_args() {
    #![expect(clippy::disallowed_macros)]
    panic!("{}", 123);
}
pub fn panic_3_args() {
    #![expect(clippy::disallowed_macros)]
    panic!("{} {}", 123, 456);
}

With this clippy.toml:

disallowed-macros = ["std::panic", "std::print"]

I saw this happen:

warning: use of a disallowed macro `std::panic`
  --> asdf.rs:20:5
   |
20 |     panic!("{}", 123);
   |     ^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
   = note: `#[warn(clippy::disallowed_macros)]` on by default

warning: this lint expectation is unfulfilled
  --> asdf.rs:19:15
   |
19 |     #![expect(clippy::disallowed_macros)]
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unfulfilled_lint_expectations)]` on by default

I expected to see this happen: no error.

With cargo +1.83.0 clippy it works, with cargo +1.84.0 clippy it no longer does. (And at least 1.82.0 and 1.81.0 also work; didn't test older than that.)

If the #![expect] lines are removed, I see six errors with both versions as expected — though 1.84.0 strangely reports the two-argument std::panic one, i.e. the problematic one that can't be silenced, as the very first error, instead of reporting the errors in source code order. Maybe that's somehow related?

Version

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5

Additional Labels

No response

@Deewiant Deewiant added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

1 participant