Remove dead lint code.

This commit is contained in:
Nicholas Nethercote 2023-11-06 15:56:41 +11:00
parent 5dfe47acd4
commit 73c1fc5bc0
3 changed files with 5 additions and 33 deletions

View File

@ -497,9 +497,6 @@ pub struct LateContext<'tcx> {
/// Items accessible from the crate being checked. /// Items accessible from the crate being checked.
pub effective_visibilities: &'tcx EffectiveVisibilities, pub effective_visibilities: &'tcx EffectiveVisibilities,
/// The store of registered lints and the lint levels.
pub lint_store: &'tcx LintStore,
pub last_node_with_lint_attrs: hir::HirId, pub last_node_with_lint_attrs: hir::HirId,
/// Generic type parameters in scope for the item we are in. /// Generic type parameters in scope for the item we are in.
@ -515,21 +512,14 @@ pub struct EarlyContext<'a> {
pub buffered: LintBuffer, pub buffered: LintBuffer,
} }
pub trait LintPassObject: Sized {} pub trait LintContext {
impl LintPassObject for EarlyLintPassObject {}
impl LintPassObject for LateLintPassObject<'_> {}
pub trait LintContext: Sized {
type PassObject: LintPassObject;
fn sess(&self) -> &Session; fn sess(&self) -> &Session;
fn lints(&self) -> &LintStore;
/// Emit a lint at the appropriate level, with an optional associated span and an existing diagnostic. /// Emit a lint at the appropriate level, with an optional associated span and an existing
/// diagnostic.
/// ///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation. /// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed
/// explanation.
/// ///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
@ -1059,17 +1049,11 @@ impl<'a> EarlyContext<'a> {
} }
impl<'tcx> LintContext for LateContext<'tcx> { impl<'tcx> LintContext for LateContext<'tcx> {
type PassObject = LateLintPassObject<'tcx>;
/// Gets the overall compiler `Session` object. /// Gets the overall compiler `Session` object.
fn sess(&self) -> &Session { fn sess(&self) -> &Session {
&self.tcx.sess &self.tcx.sess
} }
fn lints(&self) -> &LintStore {
&*self.lint_store
}
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
fn lookup<S: Into<MultiSpan>>( fn lookup<S: Into<MultiSpan>>(
&self, &self,
@ -1094,17 +1078,11 @@ impl<'tcx> LintContext for LateContext<'tcx> {
} }
impl LintContext for EarlyContext<'_> { impl LintContext for EarlyContext<'_> {
type PassObject = EarlyLintPassObject;
/// Gets the overall compiler `Session` object. /// Gets the overall compiler `Session` object.
fn sess(&self) -> &Session { fn sess(&self) -> &Session {
&self.builder.sess() &self.builder.sess()
} }
fn lints(&self) -> &LintStore {
self.builder.lint_store()
}
#[rustc_lint_diagnostics] #[rustc_lint_diagnostics]
fn lookup<S: Into<MultiSpan>>( fn lookup<S: Into<MultiSpan>>(
&self, &self,

View File

@ -353,7 +353,6 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
cached_typeck_results: Cell::new(None), cached_typeck_results: Cell::new(None),
param_env: ty::ParamEnv::empty(), param_env: ty::ParamEnv::empty(),
effective_visibilities: &tcx.effective_visibilities(()), effective_visibilities: &tcx.effective_visibilities(()),
lint_store: unerased_lint_store(tcx),
last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id), last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id),
generics: None, generics: None,
only_module: true, only_module: true,
@ -412,7 +411,6 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
cached_typeck_results: Cell::new(None), cached_typeck_results: Cell::new(None),
param_env: ty::ParamEnv::empty(), param_env: ty::ParamEnv::empty(),
effective_visibilities: &tcx.effective_visibilities(()), effective_visibilities: &tcx.effective_visibilities(()),
lint_store: unerased_lint_store(tcx),
last_node_with_lint_attrs: hir::CRATE_HIR_ID, last_node_with_lint_attrs: hir::CRATE_HIR_ID,
generics: None, generics: None,
only_module: false, only_module: false,

View File

@ -548,10 +548,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
self.features self.features
} }
pub(crate) fn lint_store(&self) -> &LintStore {
self.store
}
fn current_specs(&self) -> &FxHashMap<LintId, LevelAndSource> { fn current_specs(&self) -> &FxHashMap<LintId, LevelAndSource> {
self.provider.current_specs() self.provider.current_specs()
} }