Skip to content

Commit

Permalink
Add a helper to rename lint groups
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Feb 13, 2024
1 parent fc682da commit 72f49cb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,26 @@ impl LintStore {
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));
}

#[track_caller]
pub fn register_renamed_group(&mut self, old_name: &'static str, new_name: &'static str) {
let prev_lint = self.lint_groups.insert(
old_name,
LintGroup {
lint_ids: vec![],
is_loaded: false,
depr: Some(LintAlias { name: new_name, silent: false }),
},
);

if prev_lint.is_some() {
bug!("The lint group {old_name} has already been registered");
}

if !self.lint_groups.contains_key(new_name) {
bug!("The lint group {new_name} has not been registered");
}
}

pub fn register_removed(&mut self, name: &str, reason: &str) {
self.by_name.insert(name.into(), Removed(reason.into()));
}
Expand Down

0 comments on commit 72f49cb

Please sign in to comment.