diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-09-28 20:00:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-28 20:00:18 +0200 |
| commit | d9ee68fa4c5a8c34e8a4c02185731ea19abdb225 (patch) | |
| tree | 322622fa5930f81480585e3781982313dea9d140 | |
| parent | 733aa50968a9885a335dbe525ae3978401530cb1 (diff) | |
| parent | a09fb901cba8e03728b8444b55f334465c4db4ca (diff) | |
| download | rust-d9ee68fa4c5a8c34e8a4c02185731ea19abdb225.tar.gz rust-d9ee68fa4c5a8c34e8a4c02185731ea19abdb225.zip | |
Rollup merge of #89318 - petrochenkov:lstore, r=oli-obk
rustc_session: Remove lint store from `Session` It was added in https://github.com/rust-lang/rust/pull/75534, but after the cleanup in https://github.com/rust-lang/rust/pull/87070 it's no longer necessary.
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/queries.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 17 |
4 files changed, 4 insertions, 37 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 45ad2df8245..8aff093dd18 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<LintStore>)> { +) -> 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 2f540395b2d..a71b59b9d49 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 8cbd2ddcbfd..d235b220944 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 27215556045..87f91901141 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<rustc_feature::Features>, - lint_store: OnceCell<Lrc<dyn SessionLintStore>>, - incr_comp_session: OneThread<RefCell<IncrCompSession>>, /// 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<dyn SessionLintStore>) { - 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, |
