diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 5cc862a58d35..6529a686af82 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -67,9 +67,10 @@ pub struct LintStore { /// Lints indexed by name. by_name: FxHashMap, - /// Map of registered lint groups to what lints they expand to. The bool - /// is true if the lint group was added by a plugin. - lint_groups: FxHashMap<&'static str, (Vec, bool)>, + /// Map of registered lint groups to what lints they expand to. The first + /// bool is true if the lint group was added by a plugin. The optional string + /// is used to store the new names of deprecated lint group names. + lint_groups: FxHashMap<&'static str, (Vec, bool, Option<&'static str>)>, /// Extra info for future incompatibility lints, describing the /// issue or RFC that caused the incompatibility. @@ -221,7 +222,7 @@ impl LintStore { let lints = lints.iter().filter(|f| f.edition == Some(*edition)).map(|f| f.id) .collect::>(); if !lints.is_empty() { - self.register_group(sess, false, edition.lint_name(), lints) + self.register_group(sess, false, edition.lint_name(), None, lints) } } @@ -231,19 +232,35 @@ impl LintStore { self.future_incompatible.insert(lint.id, lint); } - self.register_group(sess, false, "future_incompatible", future_incompatible); - - + self.register_group( + sess, + false, + "future_incompatible", + None, + future_incompatible, + ); } pub fn future_incompatible(&self, id: LintId) -> Option<&FutureIncompatibleInfo> { self.future_incompatible.get(&id) } - pub fn register_group(&mut self, sess: Option<&Session>, - from_plugin: bool, name: &'static str, - to: Vec) { - let new = self.lint_groups.insert(name, (to, from_plugin)).is_none(); + pub fn register_group( + &mut self, + sess: Option<&Session>, + from_plugin: bool, + name: &'static str, + deprecated_name: Option<&'static str>, + to: Vec, + ) { + let new = self + .lint_groups + .insert(name, (to, from_plugin, None)) + .is_none(); + if let Some(deprecated) = deprecated_name { + self.lint_groups + .insert(deprecated, (vec![], from_plugin, Some(name))); + } if !new { let msg = format!("duplicate specification of lint group {}", name); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 1c2c0ad73a89..c6344cb92104 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -924,8 +924,8 @@ where ls.register_late_pass(Some(sess), true, pass); } - for (name, to) in lint_groups { - ls.register_group(Some(sess), true, name, to); + for (name, (to, deprecated_name)) in lint_groups { + ls.register_group(Some(sess), true, name, deprecated_name, to); } *sess.plugin_llvm_passes.borrow_mut() = llvm_passes; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 47e9aef6b003..46c5b0092a27 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -105,7 +105,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { macro_rules! add_lint_group { ($sess:ident, $name:expr, $($lint:ident),*) => ( - store.register_group($sess, false, $name, vec![$(LintId::of($lint)),*]); + store.register_group($sess, false, $name, None, vec![$(LintId::of($lint)),*]); ) } diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs index 5ef05cb1d6b6..6c10ac7ea5ce 100644 --- a/src/librustc_plugin/registry.rs +++ b/src/librustc_plugin/registry.rs @@ -53,7 +53,7 @@ pub struct Registry<'a> { pub late_lint_passes: Vec, #[doc(hidden)] - pub lint_groups: FxHashMap<&'static str, Vec>, + pub lint_groups: FxHashMap<&'static str, (Vec, Option<&'static str>)>, #[doc(hidden)] pub llvm_passes: Vec, @@ -170,8 +170,15 @@ impl<'a> Registry<'a> { self.late_lint_passes.push(lint_pass); } /// Register a lint group. - pub fn register_lint_group(&mut self, name: &'static str, to: Vec<&'static Lint>) { - self.lint_groups.insert(name, to.into_iter().map(|x| LintId::of(x)).collect()); + pub fn register_lint_group( + &mut self, + name: &'static str, + deprecated_name: Option<&'static str>, + to: Vec<&'static Lint> + ) { + self.lint_groups.insert(name, + (to.into_iter().map(|x| LintId::of(x)).collect(), + deprecated_name)); } /// Register an LLVM pass. diff --git a/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs index 8ccb5878c404..082f15a39dd9 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs @@ -49,5 +49,5 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_late_lint_pass(box Pass); - reg.register_lint_group("lint_me", vec![TEST_LINT, PLEASE_LINT]); + reg.register_lint_group("lint_me", None, vec![TEST_LINT, PLEASE_LINT]); } diff --git a/src/tools/clippy b/src/tools/clippy index d99cea0f1663..9abf6fca9c72 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit d99cea0f16633556871a59500c610782b07233b9 +Subproject commit 9abf6fca9c7288cb3bb99c0f7627f94b7930ee98