Skip to content

Commit 771d22d

Browse files
Rollup merge of rust-lang#89318 - petrochenkov:lstore, r=oli-obk
rustc_session: Remove lint store from `Session` It was added in rust-lang#75534, but after the cleanup in rust-lang#87070 it's no longer necessary.
2 parents fd89811 + a09fb90 commit 771d22d

File tree

4 files changed

+4
-37
lines changed

4 files changed

+4
-37
lines changed

compiler/rustc_interface/src/passes.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn register_plugins<'a>(
179179
register_lints: impl Fn(&Session, &mut LintStore),
180180
mut krate: ast::Crate,
181181
crate_name: &str,
182-
) -> Result<(ast::Crate, Lrc<LintStore>)> {
182+
) -> Result<(ast::Crate, LintStore)> {
183183
krate = sess.time("attributes_injection", || {
184184
rustc_builtin_macros::cmdline_attrs::inject(
185185
krate,
@@ -230,9 +230,6 @@ pub fn register_plugins<'a>(
230230
}
231231
});
232232

233-
let lint_store = Lrc::new(lint_store);
234-
sess.init_lint_store(lint_store.clone());
235-
236233
Ok((krate, lint_store))
237234
}
238235

compiler/rustc_interface/src/queries.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'tcx> Queries<'tcx> {
135135
let krate = self.parse()?.take();
136136

137137
let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {};
138-
let result = passes::register_plugins(
138+
let (krate, lint_store) = passes::register_plugins(
139139
self.session(),
140140
&*self.codegen_backend().metadata_loader(),
141141
self.compiler.register_lints.as_deref().unwrap_or_else(|| empty),
@@ -150,7 +150,7 @@ impl<'tcx> Queries<'tcx> {
150150
// called, which happens within passes::register_plugins().
151151
self.dep_graph_future().ok();
152152

153-
Ok(result)
153+
Ok((krate, Lrc::new(lint_store)))
154154
})
155155
}
156156

compiler/rustc_lint/src/context.rs

-15
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use rustc_serialize::json::Json;
3838
use rustc_session::lint::{BuiltinLintDiagnostics, ExternDepSpec};
3939
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
4040
use rustc_session::Session;
41-
use rustc_session::SessionLintStore;
4241
use rustc_span::lev_distance::find_best_match_for_name;
4342
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
4443
use rustc_target::abi;
@@ -75,20 +74,6 @@ pub struct LintStore {
7574
lint_groups: FxHashMap<&'static str, LintGroup>,
7675
}
7776

78-
impl SessionLintStore for LintStore {
79-
fn name_to_lint(&self, lint_name: &str) -> LintId {
80-
let lints = self
81-
.find_lints(lint_name)
82-
.unwrap_or_else(|_| panic!("Failed to find lint with name `{}`", lint_name));
83-
84-
if let &[lint] = lints.as_slice() {
85-
return lint;
86-
} else {
87-
panic!("Found mutliple lints with name `{}`: {:?}", lint_name, lints);
88-
}
89-
}
90-
}
91-
9277
/// The target of the `by_name` map, which accounts for renaming/deprecation.
9378
#[derive(Debug)]
9479
enum TargetLint {

compiler/rustc_session/src/session.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use crate::cgu_reuse_tracker::CguReuseTracker;
22
use crate::code_stats::CodeStats;
33
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
44
use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
5-
use crate::filesearch;
6-
use crate::lint::{self, LintId};
75
use crate::parse::ParseSess;
86
use crate::search_paths::{PathKind, SearchPath};
7+
use crate::{filesearch, lint};
98

109
pub use rustc_ast::attr::MarkedAttrs;
1110
pub use rustc_ast::Attribute;
@@ -41,10 +40,6 @@ use std::str::FromStr;
4140
use std::sync::Arc;
4241
use std::time::Duration;
4342

44-
pub trait SessionLintStore: sync::Send + sync::Sync {
45-
fn name_to_lint(&self, lint_name: &str) -> LintId;
46-
}
47-
4843
pub struct OptimizationFuel {
4944
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
5045
remaining: u64,
@@ -153,8 +148,6 @@ pub struct Session {
153148

154149
features: OnceCell<rustc_feature::Features>,
155150

156-
lint_store: OnceCell<Lrc<dyn SessionLintStore>>,
157-
158151
incr_comp_session: OneThread<RefCell<IncrCompSession>>,
159152
/// Used for incremental compilation tests. Will only be populated if
160153
/// `-Zquery-dep-graph` is specified.
@@ -591,13 +584,6 @@ impl Session {
591584
}
592585
}
593586

594-
pub fn init_lint_store(&self, lint_store: Lrc<dyn SessionLintStore>) {
595-
self.lint_store
596-
.set(lint_store)
597-
.map_err(|_| ())
598-
.expect("`lint_store` was initialized twice");
599-
}
600-
601587
/// Calculates the flavor of LTO to use for this compilation.
602588
pub fn lto(&self) -> config::Lto {
603589
// If our target has codegen requirements ignore the command line
@@ -1315,7 +1301,6 @@ pub fn build_session(
13151301
crate_types: OnceCell::new(),
13161302
stable_crate_id: OnceCell::new(),
13171303
features: OnceCell::new(),
1318-
lint_store: OnceCell::new(),
13191304
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
13201305
cgu_reuse_tracker,
13211306
prof,

0 commit comments

Comments
 (0)