diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 08fba2dc56fee..122b2ab73de9b 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -451,9 +451,14 @@ pub trait LintContext: Sized { fn level_src(&self, lint: &'static Lint) -> Option { self.lints().levels.get(&LintId::of(lint)).map(|ls| match ls { - &(Warn, src) => { + &(Warn, _) => { let lint_id = LintId::of(builtin::WARNINGS); - (self.lints().get_level_source(lint_id).0, src) + let warn_src = self.lints().get_level_source(lint_id); + if warn_src.0 != Warn { + warn_src + } else { + *ls + } } _ => *ls }) diff --git a/src/test/compile-fail/issue-30730.rs b/src/test/compile-fail/issue-30730.rs new file mode 100644 index 0000000000000..82804bb747406 --- /dev/null +++ b/src/test/compile-fail/issue-30730.rs @@ -0,0 +1,13 @@ +// Copyright 2016 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(warnings)] //~ NOTE: lint level defined here +use std::thread; //~ ERROR: unused import +fn main() {}