aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/mbe_expander.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mbe/src/mbe_expander.rs')
-rw-r--r--crates/mbe/src/mbe_expander.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/mbe/src/mbe_expander.rs b/crates/mbe/src/mbe_expander.rs
index 1ad8b9f8a..97bce0536 100644
--- a/crates/mbe/src/mbe_expander.rs
+++ b/crates/mbe/src/mbe_expander.rs
@@ -28,10 +28,10 @@ fn expand_rules(rules: &[crate::Rule], input: &tt::Subtree) -> ExpandResult<tt::
28 // If we find a rule that applies without errors, we're done. 28 // If we find a rule that applies without errors, we're done.
29 // Unconditionally returning the transcription here makes the 29 // Unconditionally returning the transcription here makes the
30 // `test_repeat_bad_var` test fail. 30 // `test_repeat_bad_var` test fail.
31 let ExpandResult(res, transcribe_err) = 31 let ExpandResult { value, err: transcribe_err } =
32 transcriber::transcribe(&rule.rhs, &new_match.bindings); 32 transcriber::transcribe(&rule.rhs, &new_match.bindings);
33 if transcribe_err.is_none() { 33 if transcribe_err.is_none() {
34 return ExpandResult::ok(res); 34 return ExpandResult::ok(value);
35 } 35 }
36 } 36 }
37 // Use the rule if we matched more tokens, or had fewer errors 37 // Use the rule if we matched more tokens, or had fewer errors
@@ -47,11 +47,11 @@ fn expand_rules(rules: &[crate::Rule], input: &tt::Subtree) -> ExpandResult<tt::
47 } 47 }
48 if let Some((match_, rule)) = match_ { 48 if let Some((match_, rule)) = match_ {
49 // if we got here, there was no match without errors 49 // if we got here, there was no match without errors
50 let ExpandResult(result, transcribe_err) = 50 let ExpandResult { value, err: transcribe_err } =
51 transcriber::transcribe(&rule.rhs, &match_.bindings); 51 transcriber::transcribe(&rule.rhs, &match_.bindings);
52 ExpandResult(result, match_.err.or(transcribe_err)) 52 ExpandResult { value, err: match_.err.or(transcribe_err) }
53 } else { 53 } else {
54 ExpandResult(tt::Subtree::default(), Some(ExpandError::NoMatchingRule)) 54 ExpandResult::only_err(ExpandError::NoMatchingRule)
55 } 55 }
56} 56}
57 57
@@ -143,7 +143,10 @@ mod tests {
143 } 143 }
144 144
145 fn assert_err(macro_body: &str, invocation: &str, err: ExpandError) { 145 fn assert_err(macro_body: &str, invocation: &str, err: ExpandError) {
146 assert_eq!(expand_first(&create_rules(&format_macro(macro_body)), invocation).1, Some(err)); 146 assert_eq!(
147 expand_first(&create_rules(&format_macro(macro_body)), invocation).err,
148 Some(err)
149 );
147 } 150 }
148 151
149 fn format_macro(macro_body: &str) -> String { 152 fn format_macro(macro_body: &str) -> String {