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

Regression in lint level attributes taking effect across files #5356

Closed
dtolnay opened this issue Mar 23, 2020 · 2 comments · Fixed by #5651
Closed

Regression in lint level attributes taking effect across files #5356

dtolnay opened this issue Mar 23, 2020 · 2 comments · Fixed by #5651
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

@dtolnay
Copy link
Member

dtolnay commented Mar 23, 2020

In nightly-2020-03-19, an allow attribute correctly suppresses clippy lints in out-of-line child modules. In nightly-2020-03-23 it no longer does.

src/lib.rs

#![allow(clippy::redundant_field_names)]

pub mod m;

pub struct S {
    pub x: u8,
}

src/m.rs

pub fn f(x: u8) {
    let _ = crate::S { x: x };
}
$ cargo +nightly-2020-03-19 clippy
    Checking testing v0.0.0
    Finished dev [unoptimized + debuginfo] target(s) in 0.24s

$ cargo +nightly-2020-03-23 clippy
    Checking testing v0.0.0
warning: redundant field names in struct initialization
 --> src/m.rs:2:24
  |
2 |     let _ = crate::S { x: x };
  |                        ^^^^ help: replace it with: `x`
  |
  = note: `#[warn(clippy::redundant_field_names)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

    Finished dev [unoptimized + debuginfo] target(s) in 0.23s

Inline modules (pub mod m { ... }) do not appear to be affected.

@flip1995 flip1995 added the C-bug Category: Clippy is not doing the correct thing label Mar 23, 2020
@flip1995
Copy link
Member

Is this specific for the redundant_field_names lint or does this issue apply to other lints, too?

@dtolnay
Copy link
Member Author

dtolnay commented Apr 23, 2020

Based on #5515, possibly specific to redundant_field_names. I haven't tested every other lint but I haven't noticed it for others.

flip1995 added a commit to flip1995/rust-clippy that referenced this issue Apr 25, 2020
Register redundant_field_names and non_expressive_names as early passes

Fixes rust-lang#5356
Fixes rust-lang#5521

We should move all pre_expansion_passes to early_passes, since they were soft deprecated in the rust compiler IIUC.

changelog: none
@bors bors closed this as completed in fca76de May 26, 2020
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 17, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 17, 2020
…imulacrum

[stable] stable 1.44.1

Another backport for 1.44.1, fixing rust-lang/rust-clippy#5356.

r? @ghost
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jul 7, 2020
Pkgsrc changes:
 * None.

Upstream changes:

Version 1.44.1 (2020-06-18)
===========================

* [rustfmt accepts rustfmt_skip in cfg_attr again.][73078]
* [Don't hash executable filenames on apple platforms, fixing backtraces.]
  [cargo/8329]
* [Fix crashes when finding backtrace on macOS.][71397]
* [Clippy applies lint levels into different files.][clippy/5356]

[71397]: rust-lang/rust#71397
[73078]: rust-lang/rust#73078
[cargo/8329]: rust-lang/cargo#8329
[clippy/5356]: rust-lang/rust-clippy#5356
@rustbot rustbot added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Sep 13, 2021
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
3 participants