Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_session: Remove lint store from Session #89318

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)))
})
}

Expand Down
15 changes: 0 additions & 15 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
17 changes: 1 addition & 16 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down