Change:
The following snippet works fine before but now it reports a warning: Steps to reproduce: clone rustup override set nightly-2017-08-11 cargo test Is this an expected behavior, or a bug? Thank you!
cc -- probably related to the new lint implementation
Yes this was caused by The bug is on . The check for whether is in scope is not checking the current set of attributes being linted. For example this does not warn: but this warns: (as you've noticed) The fix is to just take the local variable into account which has the up-to-that-point set of lint attributes collected.
I've opened a PR for this at

Discussion:
}); } <del> fn get_lint_level(&self, lint: &'static Lint, idx: u32) </del> <ins> fn get_lint_level(&self, lint: &'static Lint, idx: u32, aux: Option<&FxHashMap<LintId, (Level, LintSource)>>) </ins> -> (Level, LintSource) { <del> let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx); </del> <ins> let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx, aux); </ins> // If `level` is none then we actually assume the default level for this // lint.

// `allow(warnings)` in scope then we want to respect that instead. if level == Level::Warn { let (warnings_level, warnings_src) = <del> self.get_lint_id_level(LintId::of(lint::builtin::WARNINGS), idx); </del> <ins> self.get_lint_id_level(LintId::of(lint::builtin::WARNINGS), idx, aux); </ins> if let Some(configured_warning_level) = warnings_level { if configured_warning_level != Level::Warn { level = configured_warning_level;

return (level, src) } <del> fn get_lint_id_level(&self, id: LintId, mut idx: u32) </del> <ins> fn get_lint_id_level(&self, id: LintId, mut idx: u32, aux: Option<&FxHashMap<LintId, (Level, LintSource)>>) </ins> -> (Option<Level>, LintSource) { <ins> if let Some(specs) = aux { if let Some(&(level, src)) = specs.get(&id) { return (Some(level), src) } } </ins> loop { match self.list[idx as usize] { LintSet::CommandLine { ref specs } => {

specs.insert(*id, (level, src)); } } <ins> _ if !self.warn_about_weird_lints => {} </ins> CheckLintNameResult::Warning(ref msg) => { <del> if self.warn_about_weird_lints { self.struct_lint(builtin::RENAMED_AND_REMOVED_LINTS, Some(li.span.into()), msg) .emit(); } </del> <ins> let lint = builtin::RENAMED_AND_REMOVED_LINTS; let (level, src) = self.sets.get_lint_level(lint, self.cur, Some(&specs)); lint::struct_lint_level(self.sess, lint, level, src, Some(li.span.into()), msg) .emit(); </ins> } CheckLintNameResult::NoLint => { <del> if self.warn_about_weird_lints { self.struct_lint(builtin::UNKNOWN_LINTS, Some(li.span.into()), &format!("unknown lint: `{}`", name)) .emit(); } </del> <ins> let lint = builtin::UNKNOWN_LINTS; let (level, src) = self.sets.get_lint_level(lint, self.cur, Some(&specs)); let msg = format!("unknown lint: `{}`", name); lint::struct_lint_level(self.sess, lint, level, src, Some(li.span.into()), &msg) .emit(); </ins> } } }

if level == Level::Forbid { continue } <del> let forbid_src = match self.sets.get_lint_id_level(*id, self.cur) { </del> <ins> let forbid_src = match self.sets.get_lint_id_level(*id, self.cur, None) { </ins> (Some(Level::Forbid), src) => src, _ => continue, };

msg: &str) -> DiagnosticBuilder<'a> { <del> let (level, src) = self.sets.get_lint_level(lint, self.cur); </del> <ins> let (level, src) = self.sets.get_lint_level(lint, self.cur, None); </ins> lint::struct_lint_level(self.sess, lint, level, src, span, msg) }

-> Option<(Level, LintSource)> { self.id_to_set.get(&id).map(|idx| { <del> self.sets.get_lint_level(lint, *idx) </del> <ins> self.sets.get_lint_level(lint, *idx, None) </ins> }) } }

<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // compile-flags: -D warnings -D unknown-lints #![allow(unknown_lints)] #![allow(random_lint_name)] fn main() {} </ins>