Auto merge of #30804 - shssoichiro:deny-warnings-msg, r=nrc

Show clearer error message when #![deny(warnings)] escalates a warning

Addresses #30730
This commit is contained in:
bors 2016-03-09 03:34:55 -08:00
commit 4b868411af
2 changed files with 20 additions and 2 deletions

View File

@ -489,9 +489,14 @@ pub trait LintContext: Sized {
fn level_src(&self, lint: &'static Lint) -> Option<LevelSource> {
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
})

View File

@ -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 <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.
#![deny(warnings)] //~ NOTE: lint level defined here
use std::thread; //~ ERROR: unused import
fn main() {}