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
|
@ -69,7 +69,7 @@ pub fn expand_assert<'cx>(
|
|||
// If `generic_assert` is enabled, generates rich captured outputs
|
||||
//
|
||||
// FIXME(c410-f3r) See https://github.com/rust-lang/rust/issues/96949
|
||||
else if let Some(features) = cx.ecfg.features && features.generic_assert {
|
||||
else if cx.ecfg.features.generic_assert {
|
||||
context::Context::new(cx, call_site_span).build(cond_expr, panic_path())
|
||||
}
|
||||
// If `generic_assert` is not enabled, only outputs a literal "assertion failed: ..."
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn expand_cfg(
|
|||
&cfg,
|
||||
&cx.sess.parse_sess,
|
||||
cx.current_expansion.lint_node_id,
|
||||
cx.ecfg.features,
|
||||
Some(cx.ecfg.features),
|
||||
);
|
||||
MacEager::expr(cx.expr_bool(sp, matches_cfg))
|
||||
}
|
||||
|
|
|
@ -31,10 +31,11 @@ pub(crate) fn expand(
|
|||
|
||||
pub(crate) fn cfg_eval(
|
||||
sess: &Session,
|
||||
features: Option<&Features>,
|
||||
features: &Features,
|
||||
annotatable: Annotatable,
|
||||
lint_node_id: NodeId,
|
||||
) -> Annotatable {
|
||||
let features = Some(features);
|
||||
CfgEval { cfg: &mut StripUnconfigured { sess, features, config_tokens: true, lint_node_id } }
|
||||
.configure_annotatable(annotatable)
|
||||
// Since the item itself has already been configured by the `InvocationCollector`,
|
||||
|
|
|
@ -5,6 +5,7 @@ use rustc_ast::{self as ast, attr, NodeId};
|
|||
use rustc_ast_pretty::pprust;
|
||||
use rustc_expand::base::{parse_macro_name_and_helper_attrs, ExtCtxt, ResolverExpand};
|
||||
use rustc_expand::expand::{AstFragment, ExpansionConfig};
|
||||
use rustc_feature::Features;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::hygiene::AstPass;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
|
@ -46,13 +47,14 @@ struct CollectProcMacros<'a> {
|
|||
pub fn inject(
|
||||
krate: &mut ast::Crate,
|
||||
sess: &Session,
|
||||
features: &Features,
|
||||
resolver: &mut dyn ResolverExpand,
|
||||
is_proc_macro_crate: bool,
|
||||
has_proc_macro_decls: bool,
|
||||
is_test_crate: bool,
|
||||
handler: &rustc_errors::Handler,
|
||||
) {
|
||||
let ecfg = ExpansionConfig::default("proc_macro".to_string());
|
||||
let ecfg = ExpansionConfig::default("proc_macro".to_string(), features);
|
||||
let mut cx = ExtCtxt::new(sess, ecfg, resolver, None);
|
||||
|
||||
let mut collect = CollectProcMacros {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use rustc_ast::{self as ast, attr};
|
||||
use rustc_expand::base::{ExtCtxt, ResolverExpand};
|
||||
use rustc_expand::expand::ExpansionConfig;
|
||||
use rustc_feature::Features;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::edition::Edition::*;
|
||||
use rustc_span::hygiene::AstPass;
|
||||
|
@ -13,6 +14,7 @@ pub fn inject(
|
|||
pre_configured_attrs: &[ast::Attribute],
|
||||
resolver: &mut dyn ResolverExpand,
|
||||
sess: &Session,
|
||||
features: &Features,
|
||||
) -> usize {
|
||||
let orig_num_items = krate.items.len();
|
||||
let edition = sess.parse_sess.edition;
|
||||
|
@ -39,7 +41,7 @@ pub fn inject(
|
|||
let span = DUMMY_SP.with_def_site_ctxt(expn_id.to_expn_id());
|
||||
let call_site = DUMMY_SP.with_call_site_ctxt(expn_id.to_expn_id());
|
||||
|
||||
let ecfg = ExpansionConfig::default("std_lib_injection".to_string());
|
||||
let ecfg = ExpansionConfig::default("std_lib_injection".to_string(), features);
|
||||
let cx = ExtCtxt::new(sess, ecfg, resolver, None);
|
||||
|
||||
// .rev() to preserve ordering above in combination with insert(0, ...)
|
||||
|
|
|
@ -41,7 +41,12 @@ struct TestCtxt<'a> {
|
|||
|
||||
/// Traverse the crate, collecting all the test functions, eliding any
|
||||
/// existing main functions, and synthesizing a main test harness
|
||||
pub fn inject(krate: &mut ast::Crate, sess: &Session, resolver: &mut dyn ResolverExpand) {
|
||||
pub fn inject(
|
||||
krate: &mut ast::Crate,
|
||||
sess: &Session,
|
||||
features: &Features,
|
||||
resolver: &mut dyn ResolverExpand,
|
||||
) {
|
||||
let span_diagnostic = sess.diagnostic();
|
||||
let panic_strategy = sess.panic_strategy();
|
||||
let platform_panic_strategy = sess.target.panic_strategy;
|
||||
|
@ -76,7 +81,7 @@ pub fn inject(krate: &mut ast::Crate, sess: &Session, resolver: &mut dyn Resolve
|
|||
resolver,
|
||||
reexport_test_harness_main,
|
||||
krate,
|
||||
&sess.features_untracked(),
|
||||
features,
|
||||
panic_strategy,
|
||||
test_runner,
|
||||
)
|
||||
|
@ -243,9 +248,7 @@ fn generate_test_harness(
|
|||
panic_strategy: PanicStrategy,
|
||||
test_runner: Option<ast::Path>,
|
||||
) {
|
||||
let mut econfig = ExpansionConfig::default("test".to_string());
|
||||
econfig.features = Some(features);
|
||||
|
||||
let econfig = ExpansionConfig::default("test".to_string(), features);
|
||||
let ext_cx = ExtCtxt::new(sess, econfig, resolver, None);
|
||||
|
||||
let expn_id = ext_cx.resolver.expansion_for_ast_pass(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue