rustc_session: Remove lint store from Session
This commit is contained in:
parent
8a12be7412
commit
a09fb901cb
4 changed files with 4 additions and 37 deletions
|
@ -179,7 +179,7 @@ pub fn register_plugins<'a>(
|
||||||
register_lints: impl Fn(&Session, &mut LintStore),
|
register_lints: impl Fn(&Session, &mut LintStore),
|
||||||
mut krate: ast::Crate,
|
mut krate: ast::Crate,
|
||||||
crate_name: &str,
|
crate_name: &str,
|
||||||
) -> Result<(ast::Crate, Lrc<LintStore>)> {
|
) -> Result<(ast::Crate, LintStore)> {
|
||||||
krate = sess.time("attributes_injection", || {
|
krate = sess.time("attributes_injection", || {
|
||||||
rustc_builtin_macros::cmdline_attrs::inject(
|
rustc_builtin_macros::cmdline_attrs::inject(
|
||||||
krate,
|
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))
|
Ok((krate, lint_store))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl<'tcx> Queries<'tcx> {
|
||||||
let krate = self.parse()?.take();
|
let krate = self.parse()?.take();
|
||||||
|
|
||||||
let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {};
|
let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {};
|
||||||
let result = passes::register_plugins(
|
let (krate, lint_store) = passes::register_plugins(
|
||||||
self.session(),
|
self.session(),
|
||||||
&*self.codegen_backend().metadata_loader(),
|
&*self.codegen_backend().metadata_loader(),
|
||||||
self.compiler.register_lints.as_deref().unwrap_or_else(|| empty),
|
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().
|
// called, which happens within passes::register_plugins().
|
||||||
self.dep_graph_future().ok();
|
self.dep_graph_future().ok();
|
||||||
|
|
||||||
Ok(result)
|
Ok((krate, Lrc::new(lint_store)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ use rustc_serialize::json::Json;
|
||||||
use rustc_session::lint::{BuiltinLintDiagnostics, ExternDepSpec};
|
use rustc_session::lint::{BuiltinLintDiagnostics, ExternDepSpec};
|
||||||
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
|
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_session::SessionLintStore;
|
|
||||||
use rustc_span::lev_distance::find_best_match_for_name;
|
use rustc_span::lev_distance::find_best_match_for_name;
|
||||||
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
||||||
use rustc_target::abi;
|
use rustc_target::abi;
|
||||||
|
@ -75,20 +74,6 @@ pub struct LintStore {
|
||||||
lint_groups: FxHashMap<&'static str, LintGroup>,
|
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.
|
/// The target of the `by_name` map, which accounts for renaming/deprecation.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum TargetLint {
|
enum TargetLint {
|
||||||
|
|
|
@ -2,10 +2,9 @@ use crate::cgu_reuse_tracker::CguReuseTracker;
|
||||||
use crate::code_stats::CodeStats;
|
use crate::code_stats::CodeStats;
|
||||||
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
||||||
use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
|
use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
|
||||||
use crate::filesearch;
|
|
||||||
use crate::lint::{self, LintId};
|
|
||||||
use crate::parse::ParseSess;
|
use crate::parse::ParseSess;
|
||||||
use crate::search_paths::{PathKind, SearchPath};
|
use crate::search_paths::{PathKind, SearchPath};
|
||||||
|
use crate::{filesearch, lint};
|
||||||
|
|
||||||
pub use rustc_ast::attr::MarkedAttrs;
|
pub use rustc_ast::attr::MarkedAttrs;
|
||||||
pub use rustc_ast::Attribute;
|
pub use rustc_ast::Attribute;
|
||||||
|
@ -41,10 +40,6 @@ use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub trait SessionLintStore: sync::Send + sync::Sync {
|
|
||||||
fn name_to_lint(&self, lint_name: &str) -> LintId;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct OptimizationFuel {
|
pub struct OptimizationFuel {
|
||||||
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
|
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
|
||||||
remaining: u64,
|
remaining: u64,
|
||||||
|
@ -153,8 +148,6 @@ pub struct Session {
|
||||||
|
|
||||||
features: OnceCell<rustc_feature::Features>,
|
features: OnceCell<rustc_feature::Features>,
|
||||||
|
|
||||||
lint_store: OnceCell<Lrc<dyn SessionLintStore>>,
|
|
||||||
|
|
||||||
incr_comp_session: OneThread<RefCell<IncrCompSession>>,
|
incr_comp_session: OneThread<RefCell<IncrCompSession>>,
|
||||||
/// Used for incremental compilation tests. Will only be populated if
|
/// Used for incremental compilation tests. Will only be populated if
|
||||||
/// `-Zquery-dep-graph` is specified.
|
/// `-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.
|
/// Calculates the flavor of LTO to use for this compilation.
|
||||||
pub fn lto(&self) -> config::Lto {
|
pub fn lto(&self) -> config::Lto {
|
||||||
// If our target has codegen requirements ignore the command line
|
// If our target has codegen requirements ignore the command line
|
||||||
|
@ -1315,7 +1301,6 @@ pub fn build_session(
|
||||||
crate_types: OnceCell::new(),
|
crate_types: OnceCell::new(),
|
||||||
stable_crate_id: OnceCell::new(),
|
stable_crate_id: OnceCell::new(),
|
||||||
features: OnceCell::new(),
|
features: OnceCell::new(),
|
||||||
lint_store: OnceCell::new(),
|
|
||||||
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
|
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
|
||||||
cgu_reuse_tracker,
|
cgu_reuse_tracker,
|
||||||
prof,
|
prof,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue