syntax: Keep full Stability in SyntaxExtension

This commit is contained in:
Vadim Petrochenkov 2019-06-21 11:50:30 +03:00
parent 73dec4a804
commit 3542995ff9
4 changed files with 18 additions and 26 deletions

View file

@ -1,5 +1,5 @@
use crate::ast::{self, Attribute, Name, PatKind};
use crate::attr::HasAttrs;
use crate::attr::{HasAttrs, Stability};
use crate::source_map::{SourceMap, Spanned, respan};
use crate::edition::Edition;
use crate::ext::expand::{self, AstFragment, Invocation};
@ -616,8 +616,8 @@ pub struct SyntaxExtension {
pub allow_internal_unsafe: bool,
/// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro.
pub local_inner_macros: bool,
/// The macro's feature name and tracking issue number if it is unstable.
pub unstable_feature: Option<(Symbol, u32)>,
/// The macro's stability and deprecation info.
pub stability: Option<Stability>,
/// Names of helper attributes registered by this macro.
pub helper_attrs: Vec<Symbol>,
/// Edition of the crate in which this macro is defined.
@ -662,7 +662,7 @@ impl SyntaxExtension {
allow_internal_unstable: None,
allow_internal_unsafe: false,
local_inner_macros: false,
unstable_feature: None,
stability: None,
helper_attrs: Vec::new(),
edition,
kind,

View file

@ -422,8 +422,6 @@ pub fn compile(
})
});
let allow_internal_unsafe = attr::contains_name(&def.attrs, sym::allow_internal_unsafe);
let mut local_inner_macros = false;
if let Some(macro_export) = attr::find_by_name(&def.attrs, sym::macro_export) {
if let Some(l) = macro_export.meta_item_list() {
@ -431,23 +429,14 @@ pub fn compile(
}
}
let unstable_feature =
attr::find_stability(&sess, &def.attrs, def.span).and_then(|stability| {
if let attr::StabilityLevel::Unstable { issue, .. } = stability.level {
Some((stability.feature, issue))
} else {
None
}
});
SyntaxExtension {
kind: SyntaxExtensionKind::LegacyBang(expander),
span: def.span,
default_transparency,
allow_internal_unstable,
allow_internal_unsafe,
allow_internal_unsafe: attr::contains_name(&def.attrs, sym::allow_internal_unsafe),
local_inner_macros,
unstable_feature,
stability: attr::find_stability(&sess, &def.attrs, def.span),
helper_attrs: Vec::new(),
edition,
}