aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tests.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-17 09:41:30 +0000
committerGitHub <[email protected]>2020-03-17 09:41:30 +0000
commit6aa432d86b7e4fb691600032ebdf6f2301152447 (patch)
treeaa012212c11e43a95547f553b5116922631f9896 /crates/ra_mbe/src/tests.rs
parentcf4ae9aa591729dde25a7df3fa5c22ca0fd94145 (diff)
parent6c20d7e979b967eb20207414c0a0bf875bbcb98d (diff)
Merge #3580
3580: More error-resilient MBE expansion r=matklad a=flodiebold This is the beginning of an attempt to make macro-by-example expansion more resilient, so that we still get an expansion even if no rule exactly matches, with the goal to make completion work better in macro calls. The general idea is to make everything return `(T, Option<ExpandError>)` instead of `Result<T, ExpandError>`; and then to try each macro arm in turn, and somehow choose the 'best' matching rule if none matches without errors. Finding that 'best' match isn't done yet; I'm currently counting how many tokens were consumed from the args before an error, but it also needs to take into account whether there were further patterns that had nothing to match. I'll continue this later, but I'm interested whether you think this is the right path, @matklad & @edwin0cheng. Co-authored-by: Florian Diebold <[email protected]> Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_mbe/src/tests.rs')
-rw-r--r--crates/ra_mbe/src/tests.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index 6d5d1e9e6..44f381938 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -1430,7 +1430,7 @@ impl MacroFixture {
1430 let (invocation_tt, _) = 1430 let (invocation_tt, _) =
1431 ast_to_token_tree(&macro_invocation.token_tree().unwrap()).unwrap(); 1431 ast_to_token_tree(&macro_invocation.token_tree().unwrap()).unwrap();
1432 1432
1433 self.rules.expand(&invocation_tt) 1433 self.rules.expand(&invocation_tt).result()
1434 } 1434 }
1435 1435
1436 fn assert_expand_err(&self, invocation: &str, err: &ExpandError) { 1436 fn assert_expand_err(&self, invocation: &str, err: &ExpandError) {
@@ -1662,5 +1662,5 @@ fn test_expand_bad_literal() {
1662 macro_rules! foo { ($i:literal) => {}; } 1662 macro_rules! foo { ($i:literal) => {}; }
1663 "#, 1663 "#,
1664 ) 1664 )
1665 .assert_expand_err(r#"foo!(&k");"#, &ExpandError::NoMatchingRule); 1665 .assert_expand_err(r#"foo!(&k");"#, &ExpandError::BindingError("".to_string()));
1666} 1666}