diff options
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/hygiene.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 0c645fc678c..d5c0a2ca85f 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -12,6 +12,7 @@ use crate::symbol::{keywords, Symbol}; use serialize::{Encodable, Decodable, Encoder, Decoder}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::sync::Lrc; use std::{fmt, mem}; /// A SyntaxContext represents a chain of macro expansions (represented by marks). @@ -550,10 +551,10 @@ pub struct ExpnInfo { pub def_site: Option<Span>, /// The format with which the macro was invoked. pub format: ExpnFormat, - /// Whether the macro is allowed to use #[unstable]/feature-gated - /// features internally without forcing the whole crate to opt-in + /// List of #[unstable]/feature-gated features that the macro is allowed to use + /// internally without forcing the whole crate to opt-in /// to them. - pub allow_internal_unstable: bool, + pub allow_internal_unstable: Option<Lrc<[Symbol]>>, /// Whether the macro is allowed to use `unsafe` internally /// even if the user crate has `#![forbid(unsafe_code)]`. pub allow_internal_unsafe: bool, diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index dbb4f8f8159..042005ea538 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -386,9 +386,13 @@ impl Span { /// Check if a span is "internal" to a macro in which `#[unstable]` /// items can be used (that is, a macro marked with /// `#[allow_internal_unstable]`). - pub fn allows_unstable(&self) -> bool { + pub fn allows_unstable(&self, feature: &str) -> bool { match self.ctxt().outer().expn_info() { - Some(info) => info.allow_internal_unstable, + Some(info) => info + .allow_internal_unstable + .map_or(false, |features| features.iter().any(|&f| + f == feature || f == "allow_internal_unstable_backcompat_hack" + )), None => false, } } |
