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

#![allow(unknown_lints)] warns about unknown lints in another module #84936

Closed
wtfsck opened this issue May 5, 2021 · 2 comments · Fixed by #114820
Closed

#![allow(unknown_lints)] warns about unknown lints in another module #84936

wtfsck opened this issue May 5, 2021 · 2 comments · Fixed by #114820
Labels
C-bug Category: This is a bug.

Comments

@wtfsck
Copy link

wtfsck commented May 5, 2021

It seems like #![allow(unknown_lints)] only works in the same file where it was added, and not in any sub modules in other files.

lib.rs:

#![allow(unknown_lints)]
#![allow(dead_code)]
// no warning
#![allow(not_a_real_lint)]

mod other;

// no warning
#[allow(not_a_real_lint)]
fn m() {}

mod mm {
    // no warning
    #[allow(not_a_real_lint)]
    fn m() {}
}

other.rs

// warning: unknown lint: `not_a_real_lint`
#![allow(not_a_real_lint)]

// warning: unknown lint: `not_a_real_lint`
#[allow(not_a_real_lint)]
fn m() {}

I expected to see this happen:

No warnings in other.rs about unknown lints

Instead, this happened:

Warnings about unknown lints in other.rs

warning: unknown lint: `not_a_real_lint`
 --> src\other.rs:2:10
  |
2 | #![allow(not_a_real_lint)]
  |          ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unknown_lints)]` on by default

warning: unknown lint: `not_a_real_lint`
 --> src\other.rs:5:9
  |
5 | #[allow(not_a_real_lint)]
  |         ^^^^^^^^^^^^^^^

warning: unknown lint: `not_a_real_lint`
 --> src\other.rs:2:10
  |
2 | #![allow(not_a_real_lint)]
  |          ^^^^^^^^^^^^^^^

warning: 3 warnings emitted

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-pc-windows-msvc
release: 1.51.0
LLVM version: 11.0.1

Also repros with 1.52.0 beta.

@wtfsck wtfsck added the C-bug Category: This is a bug. label May 5, 2021
@wtfsck
Copy link
Author

wtfsck commented May 5, 2021

It works correctly in 1.43.1 and reports warnings in 1.44.0 and later.

@ehuss
Copy link
Contributor

ehuss commented May 5, 2021

I'm pretty sure this was an inadvertent regression from #69838.

@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@bors bors closed this as completed in dd76268 Aug 15, 2023
@fmease fmease removed the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants