Use Rc<[Symbol]>
instead of Vec<Symbol>
to reduce # of allocs
This commit is contained in:
parent
1dba7cb202
commit
b681433b9d
19 changed files with 54 additions and 50 deletions
|
@ -52,6 +52,7 @@ use crate::util::nodemap::{DefIdMap, NodeMap};
|
||||||
use std::collections::{BTreeSet, BTreeMap};
|
use std::collections::{BTreeSet, BTreeMap};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::rc::Rc;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
@ -687,7 +688,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
&self,
|
&self,
|
||||||
reason: CompilerDesugaringKind,
|
reason: CompilerDesugaringKind,
|
||||||
span: Span,
|
span: Span,
|
||||||
allow_internal_unstable: Vec<Symbol>,
|
allow_internal_unstable: Option<Rc<[Symbol]>>,
|
||||||
) -> Span {
|
) -> Span {
|
||||||
let mark = Mark::fresh(Mark::root());
|
let mark = Mark::fresh(Mark::root());
|
||||||
mark.set_expn_info(source_map::ExpnInfo {
|
mark.set_expn_info(source_map::ExpnInfo {
|
||||||
|
@ -974,9 +975,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
let unstable_span = self.mark_span_with_reason(
|
let unstable_span = self.mark_span_with_reason(
|
||||||
CompilerDesugaringKind::Async,
|
CompilerDesugaringKind::Async,
|
||||||
span,
|
span,
|
||||||
vec![
|
Some(vec![
|
||||||
Symbol::intern("gen_future"),
|
Symbol::intern("gen_future"),
|
||||||
],
|
].into()),
|
||||||
);
|
);
|
||||||
let gen_future = self.expr_std_path(
|
let gen_future = self.expr_std_path(
|
||||||
unstable_span, &["future", "from_generator"], None, ThinVec::new());
|
unstable_span, &["future", "from_generator"], None, ThinVec::new());
|
||||||
|
@ -1376,7 +1377,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
let exist_ty_span = self.mark_span_with_reason(
|
let exist_ty_span = self.mark_span_with_reason(
|
||||||
CompilerDesugaringKind::ExistentialReturnType,
|
CompilerDesugaringKind::ExistentialReturnType,
|
||||||
span,
|
span,
|
||||||
Vec::new(), // doesn'c actually allow anything unstable
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let exist_ty_def_index = self
|
let exist_ty_def_index = self
|
||||||
|
@ -3944,9 +3945,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
let unstable_span = this.mark_span_with_reason(
|
let unstable_span = this.mark_span_with_reason(
|
||||||
CompilerDesugaringKind::TryBlock,
|
CompilerDesugaringKind::TryBlock,
|
||||||
body.span,
|
body.span,
|
||||||
vec![
|
Some(vec![
|
||||||
Symbol::intern("try_trait"),
|
Symbol::intern("try_trait"),
|
||||||
],
|
].into()),
|
||||||
);
|
);
|
||||||
let mut block = this.lower_block(body, true).into_inner();
|
let mut block = this.lower_block(body, true).into_inner();
|
||||||
let tail = block.expr.take().map_or_else(
|
let tail = block.expr.take().map_or_else(
|
||||||
|
@ -4382,7 +4383,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
let desugared_span = self.mark_span_with_reason(
|
let desugared_span = self.mark_span_with_reason(
|
||||||
CompilerDesugaringKind::ForLoop,
|
CompilerDesugaringKind::ForLoop,
|
||||||
head_sp,
|
head_sp,
|
||||||
Vec::new(),
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let iter = self.str_to_ident("iter");
|
let iter = self.str_to_ident("iter");
|
||||||
|
@ -4548,9 +4549,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
let unstable_span = self.mark_span_with_reason(
|
let unstable_span = self.mark_span_with_reason(
|
||||||
CompilerDesugaringKind::QuestionMark,
|
CompilerDesugaringKind::QuestionMark,
|
||||||
e.span,
|
e.span,
|
||||||
vec![
|
Some(vec![
|
||||||
Symbol::intern("try_trait")
|
Symbol::intern("try_trait")
|
||||||
],
|
].into()),
|
||||||
);
|
);
|
||||||
|
|
||||||
// `Try::into_result(<expr>)`
|
// `Try::into_result(<expr>)`
|
||||||
|
|
|
@ -91,9 +91,9 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> {
|
||||||
call_site: item.span, // use the call site of the static
|
call_site: item.span, // use the call site of the static
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern(name)),
|
format: MacroAttribute(Symbol::intern(name)),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -570,7 +570,7 @@ impl<'a> CrateLoader<'a> {
|
||||||
ProcMacro::Bang { name, client } => {
|
ProcMacro::Bang { name, client } => {
|
||||||
(name, SyntaxExtension::ProcMacro {
|
(name, SyntaxExtension::ProcMacro {
|
||||||
expander: Box::new(BangProcMacro { client }),
|
expander: Box::new(BangProcMacro { client }),
|
||||||
allow_internal_unstable: Vec::new(),
|
allow_internal_unstable: None,
|
||||||
edition: root.edition,
|
edition: root.edition,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,9 +425,9 @@ impl cstore::CStore {
|
||||||
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
|
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
|
||||||
let ext = SyntaxExtension::ProcMacro {
|
let ext = SyntaxExtension::ProcMacro {
|
||||||
expander: Box::new(BangProcMacro { client }),
|
expander: Box::new(BangProcMacro { client }),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("proc_macro_def_site"),
|
Symbol::intern("proc_macro_def_site"),
|
||||||
],
|
].into()),
|
||||||
edition: data.root.edition,
|
edition: data.root.edition,
|
||||||
};
|
};
|
||||||
return LoadedMacro::ProcMacro(Lrc::new(ext));
|
return LoadedMacro::ProcMacro(Lrc::new(ext));
|
||||||
|
|
|
@ -126,7 +126,7 @@ impl<'a> Registry<'a> {
|
||||||
self.register_syntax_extension(Symbol::intern(name), NormalTT {
|
self.register_syntax_extension(Symbol::intern(name), NormalTT {
|
||||||
expander: Box::new(expander),
|
expander: Box::new(expander),
|
||||||
def_info: None,
|
def_info: None,
|
||||||
allow_internal_unstable: Vec::new(),
|
allow_internal_unstable: None,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
unstable_feature: None,
|
unstable_feature: None,
|
||||||
|
|
|
@ -622,7 +622,7 @@ pub enum SyntaxExtension {
|
||||||
ProcMacro {
|
ProcMacro {
|
||||||
expander: Box<dyn ProcMacro + sync::Sync + sync::Send>,
|
expander: Box<dyn ProcMacro + sync::Sync + sync::Send>,
|
||||||
/// Whitelist of unstable features that are treated as stable inside this macro
|
/// Whitelist of unstable features that are treated as stable inside this macro
|
||||||
allow_internal_unstable: Vec<Symbol>,
|
allow_internal_unstable: Option<Rc<[Symbol]>>,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ pub enum SyntaxExtension {
|
||||||
/// directly use `#[unstable]` things.
|
/// directly use `#[unstable]` things.
|
||||||
///
|
///
|
||||||
/// Only allows things that require a feature gate in the given whitelist
|
/// Only allows things that require a feature gate in the given whitelist
|
||||||
allow_internal_unstable: Vec<Symbol>,
|
allow_internal_unstable: Option<Rc<[Symbol]>>,
|
||||||
/// Whether the contents of the macro can use `unsafe`
|
/// Whether the contents of the macro can use `unsafe`
|
||||||
/// without triggering the `unsafe_code` lint.
|
/// without triggering the `unsafe_code` lint.
|
||||||
allow_internal_unsafe: bool,
|
allow_internal_unsafe: bool,
|
||||||
|
@ -660,7 +660,7 @@ pub enum SyntaxExtension {
|
||||||
IdentTT {
|
IdentTT {
|
||||||
expander: Box<dyn IdentMacroExpander + sync::Sync + sync::Send>,
|
expander: Box<dyn IdentMacroExpander + sync::Sync + sync::Send>,
|
||||||
span: Option<Span>,
|
span: Option<Span>,
|
||||||
allow_internal_unstable: Vec<Symbol>,
|
allow_internal_unstable: Option<Rc<[Symbol]>>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// An attribute-like procedural macro. TokenStream -> TokenStream.
|
/// An attribute-like procedural macro. TokenStream -> TokenStream.
|
||||||
|
|
|
@ -58,10 +58,10 @@ pub fn add_derived_markers<T>(cx: &mut ExtCtxt<'_>, span: Span, traits: &[ast::P
|
||||||
call_site: span,
|
call_site: span,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)),
|
format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
Symbol::intern("structural_match"),
|
Symbol::intern("structural_match"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -558,7 +558,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
call_site: attr.span,
|
call_site: attr.span,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern(&attr.path.to_string())),
|
format: MacroAttribute(Symbol::intern(&attr.path.to_string())),
|
||||||
allow_internal_unstable: Vec::new(),
|
allow_internal_unstable: None,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: ext.edition(),
|
edition: ext.edition(),
|
||||||
|
@ -758,7 +758,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
let opt_expanded = match *ext {
|
let opt_expanded = match *ext {
|
||||||
DeclMacro { ref expander, def_info, edition, .. } => {
|
DeclMacro { ref expander, def_info, edition, .. } => {
|
||||||
if let Err(dummy_span) = validate_and_set_expn_info(self, def_info.map(|(_, s)| s),
|
if let Err(dummy_span) = validate_and_set_expn_info(self, def_info.map(|(_, s)| s),
|
||||||
Vec::new(), false, false, None,
|
None, false, false, None,
|
||||||
edition) {
|
edition) {
|
||||||
dummy_span
|
dummy_span
|
||||||
} else {
|
} else {
|
||||||
|
@ -919,7 +919,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
call_site: span,
|
call_site: span,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(pretty_name),
|
format: MacroAttribute(pretty_name),
|
||||||
allow_internal_unstable: Vec::new(),
|
allow_internal_unstable: None,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: ext.edition(),
|
edition: ext.edition(),
|
||||||
|
@ -938,12 +938,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
Some(invoc.fragment_kind.expect_from_annotatables(items))
|
Some(invoc.fragment_kind.expect_from_annotatables(items))
|
||||||
}
|
}
|
||||||
BuiltinDerive(func) => {
|
BuiltinDerive(func) => {
|
||||||
expn_info.allow_internal_unstable = vec![
|
expn_info.allow_internal_unstable = Some(vec![
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
Symbol::intern("derive_clone_copy"),
|
Symbol::intern("derive_clone_copy"),
|
||||||
Symbol::intern("derive_eq"),
|
Symbol::intern("derive_eq"),
|
||||||
Symbol::intern("libstd_sys_internals"), // RustcDeserialize and RustcSerialize
|
Symbol::intern("libstd_sys_internals"), // RustcDeserialize and RustcSerialize
|
||||||
];
|
].into());
|
||||||
invoc.expansion_data.mark.set_expn_info(expn_info);
|
invoc.expansion_data.mark.set_expn_info(expn_info);
|
||||||
let span = span.with_ctxt(self.cx.backtrace());
|
let span = span.with_ctxt(self.cx.backtrace());
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
|
|
|
@ -377,13 +377,13 @@ pub fn compile(
|
||||||
|
|
||||||
if body.legacy {
|
if body.legacy {
|
||||||
let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable")
|
let allow_internal_unstable = attr::find_by_name(&def.attrs, "allow_internal_unstable")
|
||||||
.map_or(Vec::new(), |attr| attr
|
.map(|attr| attr
|
||||||
.meta_item_list()
|
.meta_item_list()
|
||||||
.map(|list| list.iter()
|
.map(|list| list.iter()
|
||||||
.map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
|
.map(|it| it.name().unwrap_or_else(|| sess.span_diagnostic.span_bug(
|
||||||
it.span, "allow internal unstable expects feature names",
|
it.span, "allow internal unstable expects feature names",
|
||||||
)))
|
)))
|
||||||
.collect()
|
.collect::<Vec<Symbol>>().into()
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
sess.span_diagnostic.span_warn(
|
sess.span_diagnostic.span_warn(
|
||||||
|
@ -391,7 +391,7 @@ pub fn compile(
|
||||||
future this will become a hard error. Please use `allow_internal_unstable(\
|
future this will become a hard error. Please use `allow_internal_unstable(\
|
||||||
foo, bar)` to only allow the `foo` and `bar` features",
|
foo, bar)` to only allow the `foo` and `bar` features",
|
||||||
);
|
);
|
||||||
vec![Symbol::intern("allow_internal_unstable_backcompat_hack")]
|
vec![Symbol::intern("allow_internal_unstable_backcompat_hack")].into()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe");
|
let allow_internal_unsafe = attr::contains_name(&def.attrs, "allow_internal_unsafe");
|
||||||
|
|
|
@ -20,9 +20,9 @@ fn ignored_span(sp: Span) -> Span {
|
||||||
call_site: DUMMY_SP,
|
call_site: DUMMY_SP,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern("std_inject")),
|
format: MacroAttribute(Symbol::intern("std_inject")),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("prelude_import"),
|
Symbol::intern("prelude_import"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -285,11 +285,11 @@ fn generate_test_harness(sess: &ParseSess,
|
||||||
call_site: DUMMY_SP,
|
call_site: DUMMY_SP,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern("test_case")),
|
format: MacroAttribute(Symbol::intern("test_case")),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("main"),
|
Symbol::intern("main"),
|
||||||
Symbol::intern("test"),
|
Symbol::intern("test"),
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -138,13 +138,14 @@ fn call_intrinsic(cx: &ExtCtxt<'_>,
|
||||||
-> P<ast::Expr> {
|
-> P<ast::Expr> {
|
||||||
let intrinsic_allowed_via_allow_internal_unstable = cx
|
let intrinsic_allowed_via_allow_internal_unstable = cx
|
||||||
.current_expansion.mark.expn_info().unwrap()
|
.current_expansion.mark.expn_info().unwrap()
|
||||||
.allow_internal_unstable.iter()
|
.allow_internal_unstable.map_or(false, |features| features.iter().any(|&s|
|
||||||
.any(|&s| s == "core_intrinsics");
|
s == "core_intrinsics"
|
||||||
|
));
|
||||||
if intrinsic_allowed_via_allow_internal_unstable {
|
if intrinsic_allowed_via_allow_internal_unstable {
|
||||||
span = span.with_ctxt(cx.backtrace());
|
span = span.with_ctxt(cx.backtrace());
|
||||||
} else { // Avoid instability errors with user defined curstom derives, cc #36316
|
} else { // Avoid instability errors with user defined curstom derives, cc #36316
|
||||||
let mut info = cx.current_expansion.mark.expn_info().unwrap();
|
let mut info = cx.current_expansion.mark.expn_info().unwrap();
|
||||||
info.allow_internal_unstable = vec![Symbol::intern("core_intrinsics")];
|
info.allow_internal_unstable = Some(vec![Symbol::intern("core_intrinsics")].into());
|
||||||
let mark = Mark::fresh(Mark::root());
|
let mark = Mark::fresh(Mark::root());
|
||||||
mark.set_expn_info(info);
|
mark.set_expn_info(info);
|
||||||
span = span.with_ctxt(SyntaxContext::empty().apply_mark(mark));
|
span = span.with_ctxt(SyntaxContext::empty().apply_mark(mark));
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
|
||||||
NormalTT {
|
NormalTT {
|
||||||
expander: Box::new($f as MacroExpanderFn),
|
expander: Box::new($f as MacroExpanderFn),
|
||||||
def_info: None,
|
def_info: None,
|
||||||
allow_internal_unstable: Vec::new(),
|
allow_internal_unstable: None,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
unstable_feature: None,
|
unstable_feature: None,
|
||||||
|
@ -103,9 +103,9 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
|
||||||
NormalTT {
|
NormalTT {
|
||||||
expander: Box::new(format::expand_format_args),
|
expander: Box::new(format::expand_format_args),
|
||||||
def_info: None,
|
def_info: None,
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("fmt_internals"),
|
Symbol::intern("fmt_internals"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
unstable_feature: None,
|
unstable_feature: None,
|
||||||
|
@ -115,9 +115,9 @@ pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
|
||||||
NormalTT {
|
NormalTT {
|
||||||
expander: Box::new(format::expand_format_args_nl),
|
expander: Box::new(format::expand_format_args_nl),
|
||||||
def_info: None,
|
def_info: None,
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("fmt_internals"),
|
Symbol::intern("fmt_internals"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
unstable_feature: None,
|
unstable_feature: None,
|
||||||
|
|
|
@ -333,10 +333,10 @@ fn mk_decls(
|
||||||
call_site: DUMMY_SP,
|
call_site: DUMMY_SP,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern("proc_macro")),
|
format: MacroAttribute(Symbol::intern("proc_macro")),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
Symbol::intern("proc_macro_internals"),
|
Symbol::intern("proc_macro_internals"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -66,10 +66,10 @@ pub fn expand_test_or_bench(
|
||||||
call_site: DUMMY_SP,
|
call_site: DUMMY_SP,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern("test")),
|
format: MacroAttribute(Symbol::intern("test")),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
Symbol::intern("test"),
|
Symbol::intern("test"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -41,10 +41,10 @@ pub fn expand(
|
||||||
call_site: DUMMY_SP,
|
call_site: DUMMY_SP,
|
||||||
def_site: None,
|
def_site: None,
|
||||||
format: MacroAttribute(Symbol::intern("test_case")),
|
format: MacroAttribute(Symbol::intern("test_case")),
|
||||||
allow_internal_unstable: vec![
|
allow_internal_unstable: Some(vec![
|
||||||
Symbol::intern("test"),
|
Symbol::intern("test"),
|
||||||
Symbol::intern("rustc_attrs"),
|
Symbol::intern("rustc_attrs"),
|
||||||
],
|
].into()),
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
edition: hygiene::default_edition(),
|
edition: hygiene::default_edition(),
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::symbol::{keywords, Symbol};
|
||||||
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
use serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use std::{fmt, mem};
|
use std::{fmt, mem};
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
/// A SyntaxContext represents a chain of macro expansions (represented by marks).
|
/// A SyntaxContext represents a chain of macro expansions (represented by marks).
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
|
||||||
|
@ -553,7 +554,7 @@ pub struct ExpnInfo {
|
||||||
/// List of #[unstable]/feature-gated features that the macro is allowed to use
|
/// List of #[unstable]/feature-gated features that the macro is allowed to use
|
||||||
/// internally without forcing the whole crate to opt-in
|
/// internally without forcing the whole crate to opt-in
|
||||||
/// to them.
|
/// to them.
|
||||||
pub allow_internal_unstable: Vec<Symbol>,
|
pub allow_internal_unstable: Option<Rc<[Symbol]>>,
|
||||||
/// Whether the macro is allowed to use `unsafe` internally
|
/// Whether the macro is allowed to use `unsafe` internally
|
||||||
/// even if the user crate has `#![forbid(unsafe_code)]`.
|
/// even if the user crate has `#![forbid(unsafe_code)]`.
|
||||||
pub allow_internal_unsafe: bool,
|
pub allow_internal_unsafe: bool,
|
||||||
|
|
|
@ -389,8 +389,9 @@ impl Span {
|
||||||
match self.ctxt().outer().expn_info() {
|
match self.ctxt().outer().expn_info() {
|
||||||
Some(info) => info
|
Some(info) => info
|
||||||
.allow_internal_unstable
|
.allow_internal_unstable
|
||||||
.iter()
|
.map_or(false, |features| features.iter().any(|&f|
|
||||||
.any(|&f| f == feature || f == "allow_internal_unstable_backcompat_hack"),
|
f == feature || f == "allow_internal_unstable_backcompat_hack"
|
||||||
|
)),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
NormalTT {
|
NormalTT {
|
||||||
expander: Box::new(Expander { args: args, }),
|
expander: Box::new(Expander { args: args, }),
|
||||||
def_info: None,
|
def_info: None,
|
||||||
allow_internal_unstable: Vec::new(),
|
allow_internal_unstable: None,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
local_inner_macros: false,
|
local_inner_macros: false,
|
||||||
unstable_feature: None,
|
unstable_feature: None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue