Pass crate editions to macro expansions, update tests
This commit is contained in:
parent
76bf3454da
commit
f4cbc2388f
|
@ -35,6 +35,7 @@ use std::{cmp, fs};
|
|||
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::edition::Edition;
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::visit;
|
||||
|
@ -535,7 +536,10 @@ impl<'a> CrateLoader<'a> {
|
|||
mem::transmute::<*mut u8, fn(&mut Registry)>(sym)
|
||||
};
|
||||
|
||||
struct MyRegistrar(Vec<(ast::Name, Lrc<SyntaxExtension>)>);
|
||||
struct MyRegistrar {
|
||||
extensions: Vec<(ast::Name, Lrc<SyntaxExtension>)>,
|
||||
edition: Edition,
|
||||
}
|
||||
|
||||
impl Registry for MyRegistrar {
|
||||
fn register_custom_derive(&mut self,
|
||||
|
@ -544,36 +548,38 @@ impl<'a> CrateLoader<'a> {
|
|||
attributes: &[&'static str]) {
|
||||
let attrs = attributes.iter().cloned().map(Symbol::intern).collect::<Vec<_>>();
|
||||
let derive = ProcMacroDerive::new(expand, attrs.clone());
|
||||
let derive = SyntaxExtension::ProcMacroDerive(Box::new(derive), attrs);
|
||||
self.0.push((Symbol::intern(trait_name), Lrc::new(derive)));
|
||||
let derive = SyntaxExtension::ProcMacroDerive(
|
||||
Box::new(derive), attrs, self.edition
|
||||
);
|
||||
self.extensions.push((Symbol::intern(trait_name), Lrc::new(derive)));
|
||||
}
|
||||
|
||||
fn register_attr_proc_macro(&mut self,
|
||||
name: &str,
|
||||
expand: fn(TokenStream, TokenStream) -> TokenStream) {
|
||||
let expand = SyntaxExtension::AttrProcMacro(
|
||||
Box::new(AttrProcMacro { inner: expand })
|
||||
Box::new(AttrProcMacro { inner: expand }), self.edition
|
||||
);
|
||||
self.0.push((Symbol::intern(name), Lrc::new(expand)));
|
||||
self.extensions.push((Symbol::intern(name), Lrc::new(expand)));
|
||||
}
|
||||
|
||||
fn register_bang_proc_macro(&mut self,
|
||||
name: &str,
|
||||
expand: fn(TokenStream) -> TokenStream) {
|
||||
let expand = SyntaxExtension::ProcMacro(
|
||||
Box::new(BangProcMacro { inner: expand })
|
||||
Box::new(BangProcMacro { inner: expand }), self.edition
|
||||
);
|
||||
self.0.push((Symbol::intern(name), Lrc::new(expand)));
|
||||
self.extensions.push((Symbol::intern(name), Lrc::new(expand)));
|
||||
}
|
||||
}
|
||||
|
||||
let mut my_registrar = MyRegistrar(Vec::new());
|
||||
let mut my_registrar = MyRegistrar { extensions: Vec::new(), edition: root.edition };
|
||||
registrar(&mut my_registrar);
|
||||
|
||||
// Intentionally leak the dynamic library. We can't ever unload it
|
||||
// since the library can make things that will live arbitrarily long.
|
||||
mem::forget(lib);
|
||||
my_registrar.0
|
||||
my_registrar.extensions
|
||||
}
|
||||
|
||||
/// Look for a plugin registrar. Returns library path, crate
|
||||
|
|
|
@ -518,7 +518,8 @@ impl CrateStore for cstore::CStore {
|
|||
return LoadedMacro::ProcMacro(proc_macros[id.index.to_proc_macro_index()].1.clone());
|
||||
} else if data.name == "proc_macro" &&
|
||||
self.get_crate_data(id.krate).item_name(id.index) == "quote" {
|
||||
let ext = SyntaxExtension::ProcMacro(Box::new(::proc_macro::__internal::Quoter));
|
||||
let ext = SyntaxExtension::ProcMacro(Box::new(::proc_macro::__internal::Quoter),
|
||||
data.edition());
|
||||
return LoadedMacro::ProcMacro(Lrc::new(ext));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use rustc::session::Session;
|
|||
|
||||
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT, IdentTT};
|
||||
use syntax::ext::base::MacroExpanderFn;
|
||||
use syntax::ext::hygiene;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax::ast;
|
||||
use syntax::feature_gate::AttributeType;
|
||||
|
@ -107,7 +108,8 @@ impl<'a> Registry<'a> {
|
|||
def_info: _,
|
||||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
unstable_feature
|
||||
unstable_feature,
|
||||
edition,
|
||||
} => {
|
||||
let nid = ast::CRATE_NODE_ID;
|
||||
NormalTT {
|
||||
|
@ -115,7 +117,8 @@ impl<'a> Registry<'a> {
|
|||
def_info: Some((nid, self.krate_span)),
|
||||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
unstable_feature
|
||||
unstable_feature,
|
||||
edition,
|
||||
}
|
||||
}
|
||||
IdentTT(ext, _, allow_internal_unstable) => {
|
||||
|
@ -150,6 +153,7 @@ impl<'a> Registry<'a> {
|
|||
allow_internal_unstable: false,
|
||||
allow_internal_unsafe: false,
|
||||
unstable_feature: None,
|
||||
edition: hygiene::default_edition(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -588,7 +588,8 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
let ext = Lrc::new(macro_rules::compile(&self.session.parse_sess,
|
||||
&self.session.features_untracked(),
|
||||
¯o_def));
|
||||
¯o_def,
|
||||
self.cstore.crate_edition_untracked(def_id.krate)));
|
||||
self.macro_map.insert(def_id, ext.clone());
|
||||
ext
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ use syntax::errors::DiagnosticBuilder;
|
|||
use syntax::ext::base::{self, Annotatable, Determinacy, MultiModifier, MultiDecorator};
|
||||
use syntax::ext::base::{MacroKind, SyntaxExtension, Resolver as SyntaxResolver};
|
||||
use syntax::ext::expand::{Expansion, ExpansionKind, Invocation, InvocationKind, find_attr_invoc};
|
||||
use syntax::ext::hygiene::{Mark, MarkKind};
|
||||
use syntax::ext::hygiene::{self, Mark, MarkKind};
|
||||
use syntax::ext::placeholders::placeholder;
|
||||
use syntax::ext::tt::macro_rules;
|
||||
use syntax::feature_gate::{self, emit_feature_err, GateIssue};
|
||||
|
@ -328,7 +328,7 @@ impl<'a> base::Resolver for Resolver<'a> {
|
|||
for did in self.unused_macros.iter() {
|
||||
let id_span = match *self.macro_map[did] {
|
||||
SyntaxExtension::NormalTT { def_info, .. } => def_info,
|
||||
SyntaxExtension::DeclMacro(.., osp) => osp,
|
||||
SyntaxExtension::DeclMacro(.., osp, _) => osp,
|
||||
_ => None,
|
||||
};
|
||||
if let Some((id, span)) = id_span {
|
||||
|
@ -371,7 +371,7 @@ impl<'a> Resolver<'a> {
|
|||
};
|
||||
for path in traits {
|
||||
match self.resolve_macro(scope, path, MacroKind::Derive, force) {
|
||||
Ok(ext) => if let SyntaxExtension::ProcMacroDerive(_, ref inert_attrs) = *ext {
|
||||
Ok(ext) => if let SyntaxExtension::ProcMacroDerive(_, ref inert_attrs, _) = *ext {
|
||||
if inert_attrs.contains(&attr_name) {
|
||||
// FIXME(jseyfried) Avoid `mem::replace` here.
|
||||
let dummy_item = placeholder(ExpansionKind::Items, ast::DUMMY_NODE_ID)
|
||||
|
@ -755,7 +755,7 @@ impl<'a> Resolver<'a> {
|
|||
let def_id = self.definitions.local_def_id(item.id);
|
||||
let ext = Lrc::new(macro_rules::compile(&self.session.parse_sess,
|
||||
&self.session.features_untracked(),
|
||||
item));
|
||||
item, hygiene::default_edition()));
|
||||
self.macro_map.insert(def_id, ext);
|
||||
|
||||
let def = match item.node { ast::ItemKind::MacroDef(ref def) => def, _ => unreachable!() };
|
||||
|
@ -803,14 +803,15 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
match *ext {
|
||||
// If `ext` is a procedural macro, check if we've already warned about it
|
||||
AttrProcMacro(_) | ProcMacro(_) => if !self.warned_proc_macros.insert(name) { return; },
|
||||
AttrProcMacro(..) | ProcMacro(..) =>
|
||||
if !self.warned_proc_macros.insert(name) { return; },
|
||||
_ => return,
|
||||
}
|
||||
|
||||
let warn_msg = match *ext {
|
||||
AttrProcMacro(_) => "attribute procedural macros cannot be \
|
||||
imported with `#[macro_use]`",
|
||||
ProcMacro(_) => "procedural macros cannot be imported with `#[macro_use]`",
|
||||
AttrProcMacro(..) => "attribute procedural macros cannot be \
|
||||
imported with `#[macro_use]`",
|
||||
ProcMacro(..) => "procedural macros cannot be imported with `#[macro_use]`",
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ use ast::{self, Attribute, Name, PatKind, MetaItem};
|
|||
use attr::HasAttrs;
|
||||
use codemap::{self, CodeMap, Spanned, respan};
|
||||
use syntax_pos::{Span, MultiSpan, DUMMY_SP};
|
||||
use edition::Edition;
|
||||
use errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use ext::expand::{self, Expansion, Invocation};
|
||||
use ext::hygiene::{Mark, SyntaxContext};
|
||||
use ext::hygiene::{self, Mark, SyntaxContext};
|
||||
use fold::{self, Folder};
|
||||
use parse::{self, parser, DirectoryOwnership};
|
||||
use parse::token;
|
||||
|
@ -586,13 +587,13 @@ pub enum SyntaxExtension {
|
|||
MultiModifier(Box<MultiItemModifier + sync::Sync + sync::Send>),
|
||||
|
||||
/// A function-like procedural macro. TokenStream -> TokenStream.
|
||||
ProcMacro(Box<ProcMacro + sync::Sync + sync::Send>),
|
||||
ProcMacro(Box<ProcMacro + sync::Sync + sync::Send>, Edition),
|
||||
|
||||
/// An attribute-like procedural macro. TokenStream, TokenStream -> TokenStream.
|
||||
/// The first TokenSteam is the attribute, the second is the annotated item.
|
||||
/// Allows modification of the input items and adding new items, similar to
|
||||
/// MultiModifier, but uses TokenStreams, rather than AST nodes.
|
||||
AttrProcMacro(Box<AttrProcMacro + sync::Sync + sync::Send>),
|
||||
AttrProcMacro(Box<AttrProcMacro + sync::Sync + sync::Send>, Edition),
|
||||
|
||||
/// A normal, function-like syntax extension.
|
||||
///
|
||||
|
@ -608,6 +609,8 @@ pub enum SyntaxExtension {
|
|||
allow_internal_unsafe: bool,
|
||||
/// The macro's feature name if it is unstable, and the stability feature
|
||||
unstable_feature: Option<(Symbol, u32)>,
|
||||
/// Edition of the crate in which the macro is defined
|
||||
edition: Edition,
|
||||
},
|
||||
|
||||
/// A function-like syntax extension that has an extra ident before
|
||||
|
@ -619,9 +622,8 @@ pub enum SyntaxExtension {
|
|||
/// The input is the annotated item.
|
||||
/// Allows generating code to implement a Trait for a given struct
|
||||
/// or enum item.
|
||||
ProcMacroDerive(Box<MultiItemModifier +
|
||||
sync::Sync +
|
||||
sync::Send>, Vec<Symbol> /* inert attribute names */),
|
||||
ProcMacroDerive(Box<MultiItemModifier + sync::Sync + sync::Send>,
|
||||
Vec<Symbol> /* inert attribute names */, Edition),
|
||||
|
||||
/// An attribute-like procedural macro that derives a builtin trait.
|
||||
BuiltinDerive(BuiltinDeriveFn),
|
||||
|
@ -629,7 +631,7 @@ pub enum SyntaxExtension {
|
|||
/// A declarative macro, e.g. `macro m() {}`.
|
||||
///
|
||||
/// The second element is the definition site span.
|
||||
DeclMacro(Box<TTMacroExpander + sync::Sync + sync::Send>, Option<(ast::NodeId, Span)>),
|
||||
DeclMacro(Box<TTMacroExpander + sync::Sync + sync::Send>, Option<(ast::NodeId, Span)>, Edition),
|
||||
}
|
||||
|
||||
impl SyntaxExtension {
|
||||
|
@ -660,6 +662,21 @@ impl SyntaxExtension {
|
|||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn edition(&self) -> Edition {
|
||||
match *self {
|
||||
SyntaxExtension::NormalTT { edition, .. } |
|
||||
SyntaxExtension::DeclMacro(.., edition) |
|
||||
SyntaxExtension::ProcMacro(.., edition) |
|
||||
SyntaxExtension::AttrProcMacro(.., edition) |
|
||||
SyntaxExtension::ProcMacroDerive(.., edition) => edition,
|
||||
// Unstable legacy stuff
|
||||
SyntaxExtension::IdentTT(..) |
|
||||
SyntaxExtension::MultiDecorator(..) |
|
||||
SyntaxExtension::MultiModifier(..) |
|
||||
SyntaxExtension::BuiltinDerive(..) => hygiene::default_edition(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type NamedSyntaxExtension = (Name, SyntaxExtension);
|
||||
|
|
|
@ -502,7 +502,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
span: None,
|
||||
allow_internal_unstable: false,
|
||||
allow_internal_unsafe: false,
|
||||
edition: hygiene::default_edition(),
|
||||
edition: ext.edition(),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -521,7 +521,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
items.push(item);
|
||||
Some(kind.expect_from_annotatables(items))
|
||||
}
|
||||
AttrProcMacro(ref mac) => {
|
||||
AttrProcMacro(ref mac, ..) => {
|
||||
self.gate_proc_macro_attr_item(attr.span, &item);
|
||||
let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item {
|
||||
Annotatable::Item(item) => token::NtItem(item),
|
||||
|
@ -610,7 +610,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
// can't infer this type
|
||||
unstable_feature: Option<(Symbol, u32)>| {
|
||||
unstable_feature: Option<(Symbol, u32)>,
|
||||
edition| {
|
||||
|
||||
// feature-gate the macro invocation
|
||||
if let Some((feature, issue)) = unstable_feature {
|
||||
|
@ -643,16 +644,17 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
span: def_site_span,
|
||||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
edition: hygiene::default_edition(),
|
||||
edition,
|
||||
},
|
||||
});
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let opt_expanded = match *ext {
|
||||
DeclMacro(ref expand, def_span) => {
|
||||
DeclMacro(ref expand, def_span, edition) => {
|
||||
if let Err(dummy_span) = validate_and_set_expn_info(self, def_span.map(|(_, s)| s),
|
||||
false, false, None) {
|
||||
false, false, None,
|
||||
edition) {
|
||||
dummy_span
|
||||
} else {
|
||||
kind.make_from(expand.expand(self.cx, span, mac.node.stream()))
|
||||
|
@ -665,11 +667,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
unstable_feature,
|
||||
edition,
|
||||
} => {
|
||||
if let Err(dummy_span) = validate_and_set_expn_info(self, def_info.map(|(_, s)| s),
|
||||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
unstable_feature) {
|
||||
unstable_feature,
|
||||
edition) {
|
||||
dummy_span
|
||||
} else {
|
||||
kind.make_from(expander.expand(self.cx, span, mac.node.stream()))
|
||||
|
@ -712,7 +716,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
kind.dummy(span)
|
||||
}
|
||||
|
||||
ProcMacro(ref expandfun) => {
|
||||
ProcMacro(ref expandfun, edition) => {
|
||||
if ident.name != keywords::Invalid.name() {
|
||||
let msg =
|
||||
format!("macro {}! expects no ident argument, given '{}'", path, ident);
|
||||
|
@ -731,7 +735,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
// FIXME probably want to follow macro_rules macros here.
|
||||
allow_internal_unstable: false,
|
||||
allow_internal_unsafe: false,
|
||||
edition: hygiene::default_edition(),
|
||||
edition,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -806,12 +810,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
span: None,
|
||||
allow_internal_unstable: false,
|
||||
allow_internal_unsafe: false,
|
||||
edition: hygiene::default_edition(),
|
||||
edition: ext.edition(),
|
||||
}
|
||||
};
|
||||
|
||||
match *ext {
|
||||
ProcMacroDerive(ref ext, _) => {
|
||||
ProcMacroDerive(ref ext, ..) => {
|
||||
invoc.expansion_data.mark.set_expn_info(expn_info);
|
||||
let span = span.with_ctxt(self.cx.backtrace());
|
||||
let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
use {ast, attr};
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
use edition::Edition;
|
||||
use ext::base::{DummyResult, ExtCtxt, MacResult, SyntaxExtension};
|
||||
use ext::base::{NormalTT, TTMacroExpander};
|
||||
use ext::expand::{Expansion, ExpansionKind};
|
||||
|
@ -183,7 +184,8 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
|
|||
// Holy self-referential!
|
||||
|
||||
/// Converts a `macro_rules!` invocation into a syntax extension.
|
||||
pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item) -> SyntaxExtension {
|
||||
pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item, edition: Edition)
|
||||
-> SyntaxExtension {
|
||||
let lhs_nm = ast::Ident::with_empty_ctxt(Symbol::gensym("lhs"));
|
||||
let rhs_nm = ast::Ident::with_empty_ctxt(Symbol::gensym("rhs"));
|
||||
|
||||
|
@ -298,10 +300,11 @@ pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item) -> Syntax
|
|||
def_info: Some((def.id, def.span)),
|
||||
allow_internal_unstable,
|
||||
allow_internal_unsafe,
|
||||
unstable_feature
|
||||
unstable_feature,
|
||||
edition,
|
||||
}
|
||||
} else {
|
||||
SyntaxExtension::DeclMacro(expander, Some((def.id, def.span)))
|
||||
SyntaxExtension::DeclMacro(expander, Some((def.id, def.span)), edition)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ pub mod proc_macro_impl;
|
|||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax::ast;
|
||||
use syntax::ext::base::{MacroExpanderFn, NormalTT, NamedSyntaxExtension};
|
||||
use syntax::ext::hygiene;
|
||||
use syntax::symbol::Symbol;
|
||||
|
||||
pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver,
|
||||
|
@ -74,6 +75,7 @@ pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver,
|
|||
allow_internal_unstable: false,
|
||||
allow_internal_unsafe: false,
|
||||
unstable_feature: None,
|
||||
edition: hygiene::default_edition(),
|
||||
});
|
||||
)* }
|
||||
}
|
||||
|
@ -128,7 +130,8 @@ pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver,
|
|||
def_info: None,
|
||||
allow_internal_unstable: true,
|
||||
allow_internal_unsafe: false,
|
||||
unstable_feature: None
|
||||
unstable_feature: None,
|
||||
edition: hygiene::default_edition(),
|
||||
});
|
||||
|
||||
for (name, ext) in user_exts {
|
||||
|
|
|
@ -20,6 +20,7 @@ extern crate rustc_plugin;
|
|||
|
||||
use std::borrow::ToOwned;
|
||||
use syntax::ast;
|
||||
use syntax::ext::hygiene;
|
||||
use syntax::ext::build::AstBuilder;
|
||||
use syntax::ext::base::{TTMacroExpander, ExtCtxt, MacResult, MacEager, NormalTT};
|
||||
use syntax::print::pprust;
|
||||
|
@ -54,5 +55,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
|||
allow_internal_unstable: false,
|
||||
allow_internal_unsafe: false,
|
||||
unstable_feature: None,
|
||||
edition: hygiene::default_edition(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,14 +28,14 @@ pub fn check_async() {
|
|||
|
||||
if passes_ident!(async) == 1 {} // OK
|
||||
if passes_ident!(r#async) == 1 {} // OK
|
||||
one_async::async(); // OK
|
||||
one_async::r#async(); // OK
|
||||
// one_async::async(); // ERROR, unresolved name
|
||||
// one_async::r#async(); // ERROR, unresolved name
|
||||
two_async::async(); // OK
|
||||
two_async::r#async(); // OK
|
||||
}
|
||||
|
||||
mod one_async {
|
||||
produces_async! {} // ERROR, FIXME
|
||||
// produces_async! {} // ERROR, reserved
|
||||
}
|
||||
mod two_async {
|
||||
produces_async_raw! {} // OK
|
||||
|
@ -54,13 +54,13 @@ pub fn check_proc() {
|
|||
// if passes_ident!(proc) == 1 {} // ERROR, reserved
|
||||
if passes_ident!(r#proc) == 1 {} // OK
|
||||
// one_proc::proc(); // ERROR, reserved
|
||||
// one_proc::r#proc(); // OK, FIXME
|
||||
one_proc::r#proc(); // OK
|
||||
// two_proc::proc(); // ERROR, reserved
|
||||
two_proc::r#proc(); // OK
|
||||
}
|
||||
|
||||
mod one_proc {
|
||||
// produces_proc! {} // OK, FIXME
|
||||
produces_proc! {} // OK
|
||||
}
|
||||
mod two_proc {
|
||||
produces_proc_raw! {} // OK
|
||||
|
|
|
@ -29,13 +29,13 @@ pub fn check_async() {
|
|||
// if passes_ident!(async) == 1 {} // ERROR, reserved
|
||||
if passes_ident!(r#async) == 1 {} // OK
|
||||
// one_async::async(); // ERROR, reserved
|
||||
// one_async::r#async(); // OK, FIXME
|
||||
one_async::r#async(); // OK
|
||||
// two_async::async(); // ERROR, reserved
|
||||
two_async::r#async(); // OK
|
||||
}
|
||||
|
||||
mod one_async {
|
||||
// produces_async! {} // OK, FIXME
|
||||
produces_async! {} // OK
|
||||
}
|
||||
mod two_async {
|
||||
produces_async_raw! {} // OK
|
||||
|
@ -53,14 +53,14 @@ pub fn check_proc() {
|
|||
|
||||
if passes_ident!(proc) == 1 {} // OK
|
||||
if passes_ident!(r#proc) == 1 {} // OK
|
||||
one_proc::proc(); // OK
|
||||
one_proc::r#proc(); // OK
|
||||
// one_proc::proc(); // ERROR, unresolved name
|
||||
// one_proc::r#proc(); // ERROR, unresolved name
|
||||
two_proc::proc(); // OK
|
||||
two_proc::r#proc(); // OK
|
||||
}
|
||||
|
||||
mod one_proc {
|
||||
produces_proc! {} // ERROR, FIXME
|
||||
// produces_proc! {} // ERROR, reserved
|
||||
}
|
||||
mod two_proc {
|
||||
produces_proc_raw! {} // OK
|
||||
|
|
|
@ -18,7 +18,7 @@ extern crate edition_kw_macro_2018;
|
|||
|
||||
// `async`
|
||||
mod one_async {
|
||||
produces_async! {} // ERROR, FIXME
|
||||
produces_async! {} // ERROR expected identifier, found reserved keyword
|
||||
}
|
||||
mod two_async {
|
||||
produces_async_raw! {} // OK
|
||||
|
@ -26,7 +26,7 @@ mod two_async {
|
|||
|
||||
// `proc`
|
||||
mod one_proc {
|
||||
produces_proc! {} // OK, FIXME
|
||||
produces_proc! {} // OK
|
||||
}
|
||||
mod two_proc {
|
||||
produces_proc_raw! {} // OK
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error: expected identifier, found reserved keyword `proc`
|
||||
--> $DIR/edition-keywords-2015-2018-expansion.rs:29:5
|
||||
error: expected identifier, found reserved keyword `async`
|
||||
--> $DIR/edition-keywords-2015-2018-expansion.rs:21:5
|
||||
|
|
||||
LL | produces_proc! {} // OK, FIXME
|
||||
| ^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
|
||||
LL | produces_async! {} // ERROR expected identifier, found reserved keyword
|
||||
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ extern crate edition_kw_macro_2015;
|
|||
|
||||
// `async`
|
||||
mod one_async {
|
||||
produces_async! {} // OK, FIXME
|
||||
produces_async! {} // OK
|
||||
}
|
||||
mod two_async {
|
||||
produces_async_raw! {} // OK
|
||||
|
@ -26,7 +26,7 @@ mod two_async {
|
|||
|
||||
// `proc`
|
||||
mod one_proc {
|
||||
produces_proc! {} // ERROR, FIXME
|
||||
produces_proc! {} // ERROR expected identifier, found reserved keyword
|
||||
}
|
||||
mod two_proc {
|
||||
produces_proc_raw! {} // OK
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error: expected identifier, found reserved keyword `async`
|
||||
--> $DIR/edition-keywords-2018-2015-expansion.rs:21:5
|
||||
error: expected identifier, found reserved keyword `proc`
|
||||
--> $DIR/edition-keywords-2018-2015-expansion.rs:29:5
|
||||
|
|
||||
LL | produces_async! {} // OK, FIXME
|
||||
| ^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
|
||||
LL | produces_proc! {} // ERROR expected identifier, found reserved keyword
|
||||
| ^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
|
|
Loading…
Reference in New Issue