diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-07 17:00:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-07 17:00:17 +0200 |
| commit | 3250b8ee596afc9881aee092279efaa57486d2ea (patch) | |
| tree | c445db0b21aa62544140ff60894f770dc8fade07 /src/libsyntax/ext/base.rs | |
| parent | 9cd75fb35f1d24f805c6759fd6236cd708b81ee1 (diff) | |
| parent | 941653b528deb96d5ed13935143db14c45d99d6e (diff) | |
Rollup merge of #62042 - petrochenkov:macstab, r=matthewjasper
Support stability and deprecation checking for all macros RELNOTES: Deprecation attributes on macros now have effect. Fixes https://github.com/rust-lang/rust/issues/34079 Fixes https://github.com/rust-lang/rust/issues/49912 Unblocks https://github.com/rust-lang/rust/pull/62086 Unblocks https://github.com/rust-lang/rust/pull/61000
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 318a5a3a82a..15c0b6ca5aa 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -1,5 +1,5 @@ use crate::ast::{self, Attribute, Name, PatKind}; -use crate::attr::HasAttrs; +use crate::attr::{HasAttrs, Stability, Deprecation}; use crate::source_map::{SourceMap, Spanned, respan}; use crate::edition::Edition; use crate::ext::expand::{self, AstFragment, Invocation}; @@ -606,8 +606,8 @@ pub enum SyntaxExtensionKind { pub struct SyntaxExtension { /// A syntax extension kind. pub kind: SyntaxExtensionKind, - /// Some info about the macro's definition point. - pub def_info: Option<(ast::NodeId, Span)>, + /// Span of the macro definition. + pub span: Span, /// Hygienic properties of spans produced by this macro by default. pub default_transparency: Transparency, /// Whitelist of unstable features that are treated as stable inside this macro. @@ -616,8 +616,10 @@ 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 info. + pub stability: Option<Stability>, + /// The macro's deprecation info. + pub deprecation: Option<Deprecation>, /// Names of helper attributes registered by this macro. pub helper_attrs: Vec<Symbol>, /// Edition of the crate in which this macro is defined. @@ -657,12 +659,13 @@ impl SyntaxExtension { /// Constructs a syntax extension with default properties. pub fn default(kind: SyntaxExtensionKind, edition: Edition) -> SyntaxExtension { SyntaxExtension { - def_info: None, + span: DUMMY_SP, default_transparency: kind.default_transparency(), allow_internal_unstable: None, allow_internal_unsafe: false, local_inner_macros: false, - unstable_feature: None, + stability: None, + deprecation: None, helper_attrs: Vec::new(), edition, kind, @@ -681,7 +684,7 @@ impl SyntaxExtension { ExpnInfo { call_site, format: self.expn_format(Symbol::intern(format)), - def_site: self.def_info.map(|(_, span)| span), + def_site: Some(self.span), default_transparency: self.default_transparency, allow_internal_unstable: self.allow_internal_unstable.clone(), allow_internal_unsafe: self.allow_internal_unsafe, @@ -738,7 +741,6 @@ pub struct ExpansionData { pub depth: usize, pub module: Rc<ModuleData>, pub directory_ownership: DirectoryOwnership, - pub crate_span: Option<Span>, } /// One of these is made during expansion and incrementally updated as we go; @@ -768,7 +770,6 @@ impl<'a> ExtCtxt<'a> { depth: 0, module: Rc::new(ModuleData { mod_path: Vec::new(), directory: PathBuf::new() }), directory_ownership: DirectoryOwnership::Owned { relative: None }, - crate_span: None, }, expansions: FxHashMap::default(), } |
