Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/expander.rs')
| -rw-r--r-- | crates/mbe/src/expander.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crates/mbe/src/expander.rs b/crates/mbe/src/expander.rs index f910f9f9d7..6510fefcb6 100644 --- a/crates/mbe/src/expander.rs +++ b/crates/mbe/src/expander.rs @@ -7,20 +7,29 @@ mod transcriber; use intern::Symbol; use rustc_hash::FxHashMap; -use span::{Edition, Span}; +use span::Span; -use crate::{ExpandError, ExpandErrorKind, ExpandResult, MatchedArmIndex, parser::MetaVarKind}; +use crate::{ + ExpandError, ExpandErrorKind, ExpandResult, MacroCallStyle, MatchedArmIndex, + parser::MetaVarKind, +}; pub(crate) fn expand_rules( + db: &dyn salsa::Database, rules: &[crate::Rule], input: &tt::TopSubtree<Span>, marker: impl Fn(&mut Span) + Copy, + call_style: MacroCallStyle, call_site: Span, - def_site_edition: Edition, ) -> ExpandResult<(tt::TopSubtree<Span>, MatchedArmIndex)> { let mut match_: Option<(matcher::Match<'_>, &crate::Rule, usize)> = None; for (idx, rule) in rules.iter().enumerate() { - let new_match = matcher::match_(&rule.lhs, input, def_site_edition); + // Skip any rules that aren't relevant to the call style (fn-like/attr/derive). + if call_style != rule.style { + continue; + } + + let new_match = matcher::match_(db, &rule.lhs, input); if new_match.err.is_none() { // If we find a rule that applies without errors, we're done. |