Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/lib.rs')
-rw-r--r--crates/mbe/src/lib.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs
index 3a85351266..d5de56312a 100644
--- a/crates/mbe/src/lib.rs
+++ b/crates/mbe/src/lib.rs
@@ -122,6 +122,9 @@ impl fmt::Display for CountError {
}
}
+/// Index of the matched macro arm on successful expansion.
+pub type MatchedArmIndex = Option<u32>;
+
/// This struct contains AST for a single `macro_rules` definition. What might
/// be very confusing is that AST has almost exactly the same shape as
/// `tt::TokenTree`, but there's a crucial difference: in macro rules, `$ident`
@@ -250,8 +253,9 @@ impl DeclarativeMacro {
marker: impl Fn(&mut Span) + Copy,
new_meta_vars: bool,
call_site: Span,
- ) -> ExpandResult<tt::Subtree<Span>> {
- expander::expand_rules(&self.rules, tt, marker, new_meta_vars, call_site)
+ def_site_edition: Edition,
+ ) -> ExpandResult<(tt::Subtree<Span>, MatchedArmIndex)> {
+ expander::expand_rules(&self.rules, tt, marker, new_meta_vars, call_site, def_site_edition)
}
}
@@ -329,6 +333,10 @@ impl<T, E> ValueResult<T, E> {
Self { value: Default::default(), err: Some(err) }
}
+ pub fn zip_val<U>(self, other: U) -> ValueResult<(T, U), E> {
+ ValueResult { value: (self.value, other), err: self.err }
+ }
+
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ValueResult<U, E> {
ValueResult { value: f(self.value), err: self.err }
}