Rust: #![allow(unknown_lints)] does not work if there is a unknow lint at the same level since nightly-2017-08-11-x86_64-unknown-linux-gnu

Created on 11 Aug 2017  路  3Comments  路  Source: rust-lang/rust

The following snippet works fine before nightly-2017-08-11-x86_64-unknown-linux-gnu

#![allow(unknown_lints)]
#![allow(clippy)]

but now it reports a warning:

warning: unknown lint: `clippy`
 --> /home/poc/src/../a/b.rs:2:10
  |
2 | #![allow(clippy)]
  |          ^^^^^^
  |
  = note: #[warn(unknown_lints)] on by default

Steps to reproduce:

  1. clone https://github.com/overvenus/poc.git
  2. rustup override set nightly-2017-08-11
  3. cargo test

Is this an expected behavior, or a bug? Thank you!

C-bug T-compiler regression-from-stable-to-nightly

Most helpful comment

I've opened a PR for this at https://github.com/rust-lang/rust/pull/43841

All 3 comments

cc @alexcrichton -- probably related to the new lint implementation

Yes this was caused by https://github.com/rust-lang/rust/pull/43522. The bug is on this line of code. The check for whether allow_lints is in scope is not checking the current set of attributes being linted.

For example this does not warn:

#![allow(unknown_lints)]

#[allow(clippy)]
fn main() {}

but this warns:

#![allow(unknown_lints)]
#![allow(clippy)]

fn main() {}

(as you've noticed)

The fix is to just take the local variable specs into account which has the up-to-that-point set of lint attributes collected.

I've opened a PR for this at https://github.com/rust-lang/rust/pull/43841

Was this page helpful?
0 / 5 - 0 ratings