From cd8de5426e7fa5d2a290ff1e882d25b0e0f5caff Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 9 Jan 2016 23:30:33 +0000 Subject: [PATCH 1/3] Show clearer error message when #![deny(warnings)] escalates a warning Addresses #30730 --- src/librustc/lint/context.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 08fba2dc56f..122b2ab73de 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 }) From ab52327a8303a658bd722f6bb4840c2a002338b9 Mon Sep 17 00:00:00 2001 From: Joshua Holmer Date: Tue, 12 Jan 2016 15:05:08 +0000 Subject: [PATCH 2/3] Add compile fail test for #30730 --- src/test/compile-fail/issue-30730.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/compile-fail/issue-30730.rs diff --git a/src/test/compile-fail/issue-30730.rs b/src/test/compile-fail/issue-30730.rs new file mode 100644 index 00000000000..80656ccdb6d --- /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)] +use std::thread; //~ ERROR: unused import +fn main() {} From a5bdc43a46fb02faeec64fd13b67db11197cef97 Mon Sep 17 00:00:00 2001 From: Joshua Holmer Date: Tue, 12 Jan 2016 15:16:43 +0000 Subject: [PATCH 3/3] Improve previous compile fail test --- src/test/compile-fail/issue-30730.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/compile-fail/issue-30730.rs b/src/test/compile-fail/issue-30730.rs index 80656ccdb6d..82804bb7474 100644 --- a/src/test/compile-fail/issue-30730.rs +++ b/src/test/compile-fail/issue-30730.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(warnings)] +#![deny(warnings)] //~ NOTE: lint level defined here use std::thread; //~ ERROR: unused import fn main() {}