diff --git a/src/librustc_expand/mbe/macro_check.rs b/src/librustc_expand/mbe/macro_check.rs index 10cdceefdf579..305c62a86f141 100644 --- a/src/librustc_expand/mbe/macro_check.rs +++ b/src/librustc_expand/mbe/macro_check.rs @@ -111,7 +111,7 @@ use rustc_session::lint::builtin::META_VARIABLE_MISUSE; use rustc_session::parse::ParseSess; use rustc_span::symbol::kw; use rustc_span::{symbol::Ident, MultiSpan, Span}; -use syntax::ast::NodeId; +use syntax::ast::{Name, NodeId}; use syntax::token::{DelimToken, Token, TokenKind}; use smallvec::SmallVec; @@ -179,7 +179,7 @@ struct BinderInfo { } /// An environment of meta-variables to their binder information. -type Binders = FxHashMap; +type Binders = FxHashMap; /// The state at which we entered a macro definition in the RHS of another macro definition. struct MacroState<'a> { @@ -246,14 +246,14 @@ fn check_binders( sess.span_diagnostic.span_bug(span, "unexpected MetaVar in lhs"); } // There are 3 possibilities: - if let Some(prev_info) = binders.get(&name) { + if let Some(prev_info) = binders.get(&name.name) { // 1. The meta-variable is already bound in the current LHS: This is an error. let mut span = MultiSpan::from_span(span); span.push_span_label(prev_info.span, "previous declaration".into()); buffer_lint(sess, span, node_id, "duplicate matcher binding"); } else if get_binder_info(macros, binders, name).is_none() { // 2. The meta-variable is free: This is a binder. - binders.insert(name, BinderInfo { span, ops: ops.into() }); + binders.insert(name.name, BinderInfo { span, ops: ops.into() }); } else { // 3. The meta-variable is bound: This is an occurrence. check_occurrences(sess, node_id, lhs, macros, binders, ops, valid); @@ -274,7 +274,7 @@ fn check_binders( .emit(); *valid = false; } else { - binders.insert(name, BinderInfo { span, ops: ops.into() }); + binders.insert(name.name, BinderInfo { span, ops: ops.into() }); } } TokenTree::Delimited(_, ref del) => { @@ -302,7 +302,7 @@ fn get_binder_info<'a>( binders: &'a Binders, name: Ident, ) -> Option<&'a BinderInfo> { - binders.get(&name).or_else(|| macros.find_map(|state| state.binders.get(&name))) + binders.get(&name.name).or_else(|| macros.find_map(|state| state.binders.get(&name.name))) } /// Checks `rhs` as part of the RHS of a macro definition and sets `valid` to false in case of @@ -560,7 +560,7 @@ fn check_ops_is_prefix( let mut acc: SmallVec<[&SmallVec<[KleeneToken; 1]>; 1]> = SmallVec::new(); for state in ¯os { acc.push(&state.ops); - if let Some(binder) = state.binders.get(&name) { + if let Some(binder) = state.binders.get(&name.name) { // This variable concatenates the stack of operators from the RHS of the LHS where the // meta-variable was defined to where it is used (in possibly nested macros). The // outermost operator is first. diff --git a/src/librustc_expand/mbe/macro_parser.rs b/src/librustc_expand/mbe/macro_parser.rs index 6599e92222c75..7396e44335ddd 100644 --- a/src/librustc_expand/mbe/macro_parser.rs +++ b/src/librustc_expand/mbe/macro_parser.rs @@ -275,7 +275,7 @@ crate enum ParseResult { /// A `ParseResult` where the `Success` variant contains a mapping of `Ident`s to `NamedMatch`es. /// This represents the mapping of metavars to the token trees they bind to. -crate type NamedParseResult = ParseResult>; +crate type NamedParseResult = ParseResult>; /// Count how many metavars are named in the given matcher `ms`. pub(super) fn count_names(ms: &[TokenTree]) -> usize { @@ -368,7 +368,7 @@ fn nameize>( sess: &ParseSess, m: &TokenTree, res: &mut I, - ret_val: &mut FxHashMap, + ret_val: &mut FxHashMap, ) -> Result<(), (rustc_span::Span, String)> { match *m { TokenTree::Sequence(_, ref seq) => { @@ -386,7 +386,7 @@ fn nameize>( return Err((span, "missing fragment specifier".to_string())); } } - TokenTree::MetaVarDecl(sp, bind_name, _) => match ret_val.entry(bind_name) { + TokenTree::MetaVarDecl(sp, bind_name, _) => match ret_val.entry(bind_name.name) { Vacant(spot) => { spot.insert(res.next().unwrap()); } diff --git a/src/librustc_expand/mbe/macro_rules.rs b/src/librustc_expand/mbe/macro_rules.rs index 52e581e30f537..64e29582949b6 100644 --- a/src/librustc_expand/mbe/macro_rules.rs +++ b/src/librustc_expand/mbe/macro_rules.rs @@ -411,7 +411,7 @@ pub fn compile_declarative_macro( let mut valid = true; // Extract the arguments: - let lhses = match argument_map[&lhs_nm] { + let lhses = match argument_map[&lhs_nm.name] { MatchedSeq(ref s) => s .iter() .map(|m| { @@ -428,7 +428,7 @@ pub fn compile_declarative_macro( _ => sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs"), }; - let rhses = match argument_map[&rhs_nm] { + let rhses = match argument_map[&rhs_nm.name] { MatchedSeq(ref s) => s .iter() .map(|m| { diff --git a/src/librustc_expand/mbe/transcribe.rs b/src/librustc_expand/mbe/transcribe.rs index 104a5233c9d8c..716870e0a33fe 100644 --- a/src/librustc_expand/mbe/transcribe.rs +++ b/src/librustc_expand/mbe/transcribe.rs @@ -7,7 +7,7 @@ use rustc_data_structures::sync::Lrc; use rustc_errors::pluralize; use rustc_span::hygiene::{ExpnId, Transparency}; use rustc_span::Span; -use syntax::ast::{Ident, Mac}; +use syntax::ast::{Ident, Mac, Name}; use syntax::mut_visit::{self, MutVisitor}; use syntax::token::{self, NtTT, Token}; use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; @@ -81,7 +81,7 @@ impl Iterator for Frame { /// Along the way, we do some additional error checking. pub(super) fn transcribe( cx: &ExtCtxt<'_>, - interp: &FxHashMap, + interp: &FxHashMap, src: Vec, transparency: Transparency, ) -> TokenStream { @@ -289,10 +289,10 @@ pub(super) fn transcribe( /// made a mistake, and we return `None`. fn lookup_cur_matched<'a>( ident: Ident, - interpolations: &'a FxHashMap, + interpolations: &'a FxHashMap, repeats: &[(usize, usize)], ) -> Option<&'a NamedMatch> { - interpolations.get(&ident).map(|matched| { + interpolations.get(&ident.name).map(|matched| { let mut matched = matched; for &(idx, _) in repeats { match matched { @@ -361,7 +361,7 @@ impl LockstepIterSize { /// multiple nested matcher sequences. fn lockstep_iter_size( tree: &mbe::TokenTree, - interpolations: &FxHashMap, + interpolations: &FxHashMap, repeats: &[(usize, usize)], ) -> LockstepIterSize { use mbe::TokenTree;