rustc: Move features
from Session
to GlobalCtxt
Removes two pieces of mutable state. Follow up to #114622.
This commit is contained in:
parent
a07bc13e14
commit
7353c96be8
30 changed files with 130 additions and 93 deletions
|
@ -13,6 +13,7 @@ use rustc_ast::*;
|
|||
use rustc_ast::{walk_list, StaticItem};
|
||||
use rustc_ast_pretty::pprust::{self, State};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_feature::Features;
|
||||
use rustc_macros::Subdiagnostic;
|
||||
use rustc_parse::validate_attr;
|
||||
use rustc_session::lint::builtin::{
|
||||
|
@ -45,6 +46,7 @@ enum DisallowTildeConstContext<'a> {
|
|||
|
||||
struct AstValidator<'a> {
|
||||
session: &'a Session,
|
||||
features: &'a Features,
|
||||
|
||||
/// The span of the `extern` in an `extern { ... }` block, if any.
|
||||
extern_mod: Option<&'a Item>,
|
||||
|
@ -1023,7 +1025,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
self.check_type_no_bounds(bounds, "this context");
|
||||
|
||||
if self.session.features_untracked().lazy_type_alias {
|
||||
if self.features.lazy_type_alias {
|
||||
if let Err(err) = self.check_type_alias_where_clause_location(ty_alias) {
|
||||
self.err_handler().emit_err(err);
|
||||
}
|
||||
|
@ -1500,9 +1502,15 @@ fn deny_equality_constraints(
|
|||
this.err_handler().emit_err(err);
|
||||
}
|
||||
|
||||
pub fn check_crate(session: &Session, krate: &Crate, lints: &mut LintBuffer) -> bool {
|
||||
pub fn check_crate(
|
||||
session: &Session,
|
||||
features: &Features,
|
||||
krate: &Crate,
|
||||
lints: &mut LintBuffer,
|
||||
) -> bool {
|
||||
let mut validator = AstValidator {
|
||||
session,
|
||||
features,
|
||||
extern_mod: None,
|
||||
in_trait_impl: false,
|
||||
in_const_trait_impl: false,
|
||||
|
|
|
@ -514,10 +514,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(krate: &ast::Crate, sess: &Session) {
|
||||
maybe_stage_features(sess, krate);
|
||||
check_incompatible_features(sess);
|
||||
let mut visitor = PostExpansionVisitor { sess, features: &sess.features_untracked() };
|
||||
pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
|
||||
maybe_stage_features(sess, features, krate);
|
||||
check_incompatible_features(sess, features);
|
||||
let mut visitor = PostExpansionVisitor { sess, features };
|
||||
|
||||
let spans = sess.parse_sess.gated_spans.spans.borrow();
|
||||
macro_rules! gate_all {
|
||||
|
@ -600,12 +600,12 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
|
|||
visit::walk_crate(&mut visitor, krate);
|
||||
}
|
||||
|
||||
fn maybe_stage_features(sess: &Session, krate: &ast::Crate) {
|
||||
fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate) {
|
||||
// checks if `#![feature]` has been used to enable any lang feature
|
||||
// does not check the same for lib features unless there's at least one
|
||||
// declared lang feature
|
||||
if !sess.opts.unstable_features.is_nightly_build() {
|
||||
let lang_features = &sess.features_untracked().declared_lang_features;
|
||||
let lang_features = &features.declared_lang_features;
|
||||
if lang_features.len() == 0 {
|
||||
return;
|
||||
}
|
||||
|
@ -640,9 +640,7 @@ fn maybe_stage_features(sess: &Session, krate: &ast::Crate) {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_incompatible_features(sess: &Session) {
|
||||
let features = sess.features_untracked();
|
||||
|
||||
fn check_incompatible_features(sess: &Session, features: &Features) {
|
||||
let declared_features = features
|
||||
.declared_lang_features
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue