diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 45ad2df82455b..8aff093dd1826 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -179,7 +179,7 @@ pub fn register_plugins<'a>( register_lints: impl Fn(&Session, &mut LintStore), mut krate: ast::Crate, crate_name: &str, -) -> Result<(ast::Crate, Lrc)> { +) -> Result<(ast::Crate, LintStore)> { krate = sess.time("attributes_injection", || { rustc_builtin_macros::cmdline_attrs::inject( krate, @@ -230,9 +230,6 @@ pub fn register_plugins<'a>( } }); - let lint_store = Lrc::new(lint_store); - sess.init_lint_store(lint_store.clone()); - Ok((krate, lint_store)) } diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 2f540395b2d79..a71b59b9d49bd 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -135,7 +135,7 @@ impl<'tcx> Queries<'tcx> { let krate = self.parse()?.take(); let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {}; - let result = passes::register_plugins( + let (krate, lint_store) = passes::register_plugins( self.session(), &*self.codegen_backend().metadata_loader(), self.compiler.register_lints.as_deref().unwrap_or_else(|| empty), @@ -150,7 +150,7 @@ impl<'tcx> Queries<'tcx> { // called, which happens within passes::register_plugins(). self.dep_graph_future().ok(); - Ok(result) + Ok((krate, Lrc::new(lint_store))) }) } diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 8cbd2ddcbfdf7..d235b2209444e 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -38,7 +38,6 @@ use rustc_serialize::json::Json; use rustc_session::lint::{BuiltinLintDiagnostics, ExternDepSpec}; use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId}; use rustc_session::Session; -use rustc_session::SessionLintStore; use rustc_span::lev_distance::find_best_match_for_name; use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP}; use rustc_target::abi; @@ -75,20 +74,6 @@ pub struct LintStore { lint_groups: FxHashMap<&'static str, LintGroup>, } -impl SessionLintStore for LintStore { - fn name_to_lint(&self, lint_name: &str) -> LintId { - let lints = self - .find_lints(lint_name) - .unwrap_or_else(|_| panic!("Failed to find lint with name `{}`", lint_name)); - - if let &[lint] = lints.as_slice() { - return lint; - } else { - panic!("Found mutliple lints with name `{}`: {:?}", lint_name, lints); - } - } -} - /// The target of the `by_name` map, which accounts for renaming/deprecation. #[derive(Debug)] enum TargetLint { diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 27215556045be..87f9190114109 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -2,10 +2,9 @@ use crate::cgu_reuse_tracker::CguReuseTracker; use crate::code_stats::CodeStats; pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo}; use crate::config::{self, CrateType, OutputType, SwitchWithOptPath}; -use crate::filesearch; -use crate::lint::{self, LintId}; use crate::parse::ParseSess; use crate::search_paths::{PathKind, SearchPath}; +use crate::{filesearch, lint}; pub use rustc_ast::attr::MarkedAttrs; pub use rustc_ast::Attribute; @@ -41,10 +40,6 @@ use std::str::FromStr; use std::sync::Arc; use std::time::Duration; -pub trait SessionLintStore: sync::Send + sync::Sync { - fn name_to_lint(&self, lint_name: &str) -> LintId; -} - pub struct OptimizationFuel { /// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`. remaining: u64, @@ -153,8 +148,6 @@ pub struct Session { features: OnceCell, - lint_store: OnceCell>, - incr_comp_session: OneThread>, /// Used for incremental compilation tests. Will only be populated if /// `-Zquery-dep-graph` is specified. @@ -591,13 +584,6 @@ impl Session { } } - pub fn init_lint_store(&self, lint_store: Lrc) { - self.lint_store - .set(lint_store) - .map_err(|_| ()) - .expect("`lint_store` was initialized twice"); - } - /// Calculates the flavor of LTO to use for this compilation. pub fn lto(&self) -> config::Lto { // If our target has codegen requirements ignore the command line @@ -1315,7 +1301,6 @@ pub fn build_session( crate_types: OnceCell::new(), stable_crate_id: OnceCell::new(), features: OnceCell::new(), - lint_store: OnceCell::new(), incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)), cgu_reuse_tracker, prof,