Add deprecated_name argument to the register lint group functions
This commit is contained in:
parent
9521deecc4
commit
ce173c12e6
@ -67,9 +67,10 @@ pub struct LintStore {
|
||||
/// Lints indexed by name.
|
||||
by_name: FxHashMap<String, TargetLint>,
|
||||
|
||||
/// 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<LintId>, 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<LintId>, 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::<Vec<_>>();
|
||||
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<LintId>) {
|
||||
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<LintId>,
|
||||
) {
|
||||
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);
|
||||
|
@ -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;
|
||||
|
@ -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)),*]);
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ pub struct Registry<'a> {
|
||||
pub late_lint_passes: Vec<LateLintPassObject>,
|
||||
|
||||
#[doc(hidden)]
|
||||
pub lint_groups: FxHashMap<&'static str, Vec<LintId>>,
|
||||
pub lint_groups: FxHashMap<&'static str, (Vec<LintId>, Option<&'static str>)>,
|
||||
|
||||
#[doc(hidden)]
|
||||
pub llvm_passes: Vec<String>,
|
||||
@ -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.
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d99cea0f16633556871a59500c610782b07233b9
|
||||
Subproject commit 9abf6fca9c7288cb3bb99c0f7627f94b7930ee98
|
Loading…
Reference in New Issue
Block a user