From e5b3de30a159a30a63d61df27bf7a8921a57a7a7 Mon Sep 17 00:00:00 2001 From: David Peter Date: Fri, 1 Aug 2025 09:49:34 +0200 Subject: [PATCH] [ty] Remove unused lint registry functionality --- crates/ty_python_semantic/src/lint.rs | 58 --------------------------- 1 file changed, 58 deletions(-) diff --git a/crates/ty_python_semantic/src/lint.rs b/crates/ty_python_semantic/src/lint.rs index 0800ee5983..ad4c528888 100644 --- a/crates/ty_python_semantic/src/lint.rs +++ b/crates/ty_python_semantic/src/lint.rs @@ -319,30 +319,6 @@ impl LintRegistryBuilder { } } - #[track_caller] - pub fn register_alias(&mut self, from: LintName, to: &'static LintMetadata) { - let target = match self.by_name.get(to.name.as_str()) { - Some(LintEntry::Lint(target) | LintEntry::Removed(target)) => target, - Some(LintEntry::Alias(target)) => { - panic!( - "lint alias {from} -> {to:?} points to another alias {target:?}", - target = target.name() - ) - } - None => panic!( - "lint alias {from} -> {to} points to non-registered lint", - to = to.name - ), - }; - - assert_eq!( - self.by_name - .insert(from.as_str(), LintEntry::Alias(*target)), - None, - "duplicate lint registration for '{from}'", - ); - } - pub fn build(self) -> LintRegistry { LintRegistry { lints: self.lints, @@ -362,13 +338,6 @@ impl LintRegistry { pub fn get(&self, code: &str) -> Result { match self.by_name.get(code) { Some(LintEntry::Lint(metadata)) => Ok(*metadata), - Some(LintEntry::Alias(lint)) => { - if lint.status.is_removed() { - Err(GetLintError::Removed(lint.name())) - } else { - Ok(*lint) - } - } Some(LintEntry::Removed(lint)) => Err(GetLintError::Removed(lint.name())), None => { if let Some(without_prefix) = DiagnosticId::strip_category(code) { @@ -390,19 +359,6 @@ impl LintRegistry { &self.lints } - /// Returns an iterator over all known aliases and to their target lints. - /// - /// This iterator includes aliases that point to removed lints. - pub fn aliases(&self) -> impl Iterator + '_ { - self.by_name.iter().filter_map(|(key, value)| { - if let LintEntry::Alias(alias) = value { - Some((LintName::of(key), *alias)) - } else { - None - } - }) - } - /// Iterates over all removed lints. pub fn removed(&self) -> impl Iterator + '_ { self.by_name.iter().filter_map(|(_, value)| { @@ -440,7 +396,6 @@ pub enum LintEntry { Lint(LintId), /// A lint rule that has been removed. Removed(LintId), - Alias(LintId), } impl LintEntry { @@ -448,7 +403,6 @@ impl LintEntry { match self { LintEntry::Lint(id) => id, LintEntry::Removed(id) => id, - LintEntry::Alias(id) => id, } } } @@ -502,18 +456,6 @@ impl RuleSelection { RuleSelection { lints } } - /// Returns an iterator over all enabled lints. - pub fn enabled(&self) -> impl Iterator + '_ { - self.lints.keys().copied() - } - - /// Returns an iterator over all enabled lints and their severity. - pub fn iter(&self) -> impl ExactSizeIterator + '_ { - self.lints - .iter() - .map(|(&lint, &(severity, _))| (lint, severity)) - } - /// Returns the configured severity for the lint with the given id or `None` if the lint is disabled. pub fn severity(&self, lint: LintId) -> Option { self.lints.get(&lint).map(|(severity, _)| *severity)