rustc: Move features from Session to GlobalCtxt
Removes two pieces of mutable state. Follow up to #114622.
This commit is contained in:
@@ -12,6 +12,7 @@ use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{DecorateLint, DiagnosticBuilder, DiagnosticMessage, MultiSpan};
|
||||
use rustc_feature::Features;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::HirId;
|
||||
@@ -119,6 +120,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
|
||||
|
||||
let mut builder = LintLevelsBuilder {
|
||||
sess: tcx.sess,
|
||||
features: tcx.features(),
|
||||
provider: QueryMapExpectationsWrapper {
|
||||
tcx,
|
||||
cur: hir::CRATE_HIR_ID,
|
||||
@@ -148,6 +150,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
|
||||
|
||||
let mut levels = LintLevelsBuilder {
|
||||
sess: tcx.sess,
|
||||
features: tcx.features(),
|
||||
provider: LintLevelQueryMap {
|
||||
tcx,
|
||||
cur: owner.into(),
|
||||
@@ -435,6 +438,7 @@ impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, QueryMapExpectationsWrapper<'
|
||||
|
||||
pub struct LintLevelsBuilder<'s, P> {
|
||||
sess: &'s Session,
|
||||
features: &'s Features,
|
||||
provider: P,
|
||||
warn_about_weird_lints: bool,
|
||||
store: &'s LintStore,
|
||||
@@ -448,12 +452,14 @@ pub(crate) struct BuilderPush {
|
||||
impl<'s> LintLevelsBuilder<'s, TopDown> {
|
||||
pub(crate) fn new(
|
||||
sess: &'s Session,
|
||||
features: &'s Features,
|
||||
warn_about_weird_lints: bool,
|
||||
store: &'s LintStore,
|
||||
registered_tools: &'s RegisteredTools,
|
||||
) -> Self {
|
||||
let mut builder = LintLevelsBuilder {
|
||||
sess,
|
||||
features,
|
||||
provider: TopDown { sets: LintLevelSets::new(), cur: COMMAND_LINE },
|
||||
warn_about_weird_lints,
|
||||
store,
|
||||
@@ -526,6 +532,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
self.sess
|
||||
}
|
||||
|
||||
pub(crate) fn features(&self) -> &Features {
|
||||
self.features
|
||||
}
|
||||
|
||||
pub(crate) fn lint_store(&self) -> &LintStore {
|
||||
self.store
|
||||
}
|
||||
@@ -716,7 +726,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
ast::MetaItemKind::NameValue(ref name_value) => {
|
||||
if item.path == sym::reason {
|
||||
if let ast::LitKind::Str(rationale, _) = name_value.kind {
|
||||
if !self.sess.features_untracked().lint_reasons {
|
||||
if !self.features.lint_reasons {
|
||||
feature_err(
|
||||
&self.sess.parse_sess,
|
||||
sym::lint_reasons,
|
||||
@@ -992,7 +1002,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
||||
#[track_caller]
|
||||
fn check_gated_lint(&self, lint_id: LintId, span: Span) -> bool {
|
||||
if let Some(feature) = lint_id.lint.feature_gate {
|
||||
if !self.sess.features_untracked().enabled(feature) {
|
||||
if !self.features.enabled(feature) {
|
||||
let lint = builtin::UNKNOWN_LINTS;
|
||||
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
|
||||
struct_lint_level(
|
||||
|
||||
Reference in New Issue
Block a user