}
}
-enum CheckLintNameResult<'a> {
+enum CheckLintNameResult {
Ok,
// Lint doesn't exist
NoLint,
- // The lint is either renamed or removed and a warning was
- // generated in the DiagnosticBuilder
- Mentioned(DiagnosticBuilder<'a>)
+ // The lint is either renamed or removed. This is the warning
+ // message.
+ Warning(String)
}
/// Checks the name of a lint for its existence, and whether it was
/// it emits non-fatal warnings and there are *two* lint passes that
/// inspect attributes, this is only run from the late pass to avoid
/// printing duplicate warnings.
-fn check_lint_name<'a>(sess: &'a Session,
- lint_cx: &LintStore,
- lint_name: &str,
- span: Option<Span>) -> CheckLintNameResult<'a> {
+fn check_lint_name(lint_cx: &LintStore,
+ lint_name: &str) -> CheckLintNameResult {
match lint_cx.by_name.get(lint_name) {
Some(&Renamed(ref new_name, _)) => {
- let warning = format!("lint {} has been renamed to {}",
- lint_name, new_name);
- let db = match span {
- Some(span) => sess.struct_span_warn(span, &warning[..]),
- None => sess.struct_warn(&warning[..]),
- };
- CheckLintNameResult::Mentioned(db)
+ CheckLintNameResult::Warning(
+ format!("lint {} has been renamed to {}", lint_name, new_name)
+ )
},
Some(&Removed(ref reason)) => {
- let warning = format!("lint {} has been removed: {}", lint_name, reason);
- let db = match span {
- Some(span) => sess.struct_span_warn(span, &warning[..]),
- None => sess.struct_warn(&warning[..])
- };
- CheckLintNameResult::Mentioned(db)
+ CheckLintNameResult::Warning(
+ format!("lint {} has been removed: {}", lint_name, reason)
+ )
},
None => {
match lint_cx.lint_groups.get(lint_name) {
continue;
}
Ok((lint_name, _, span)) => {
- match check_lint_name(&cx.tcx.sess, &cx.lints, &lint_name[..], Some(span)) {
+ match check_lint_name(&cx.lints,
+ &lint_name[..]) {
CheckLintNameResult::Ok => (),
- CheckLintNameResult::Mentioned(mut db) => {
- db.emit();
+ CheckLintNameResult::Warning(ref msg) => {
+ cx.span_lint(builtin::RENAMED_AND_REMOVED_LINTS,
+ span, msg);
}
CheckLintNameResult::NoLint => {
cx.span_lint(builtin::UNKNOWN_LINTS, span,
// Checks the validity of lint names derived from the command line
fn check_lint_name_cmdline(sess: &Session, lint_cx: &LintStore,
lint_name: &str, level: Level) {
- let db = match check_lint_name(sess, lint_cx, lint_name, None) {
+ let db = match check_lint_name(lint_cx, lint_name) {
CheckLintNameResult::Ok => None,
- CheckLintNameResult::Mentioned(db) => Some(db),
+ CheckLintNameResult::Warning(ref msg) => {
+ Some(sess.struct_warn(msg))
+ },
CheckLintNameResult::NoLint => {
Some(sess.struct_err(&format!("unknown lint: `{}`", lint_name)))
}
--- /dev/null
+// 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.
+
+// No warnings about removed lint when
+// allow(renamed_and_removed_lints)
+
+#[deny(raw_pointer_derive)]
+#[allow(renamed_and_removed_lints)]
+#[deny(unused_variables)]
+fn main() { let unused = (); } //~ ERR unused
--- /dev/null
+// 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.
+
+// No warnings about renamed lint when
+// allow(renamed_and_removed_lints)
+
+#[deny(unknown_features)]
+#[allow(renamed_and_removed_lints)]
+#[deny(unused)]
+fn main() { let unused = (); } //~ ERR unused