aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/expander
diff options
context:
space:
mode:
authorKevin Mehall <[email protected]>2021-03-20 23:43:51 +0000
committerKevin Mehall <[email protected]>2021-03-20 23:54:57 +0000
commit0a7f28620a7002f47890c2030862052bcbf25cdb (patch)
treede1a04ded1589c0a3fa504cba606bfc8d89b3aa2 /crates/mbe/src/expander
parent0a0e22235b7ad222be1aaa7765b580f4096c9aeb (diff)
Fix and test edge cases of `_` as ident
Diffstat (limited to 'crates/mbe/src/expander')
-rw-r--r--crates/mbe/src/expander/matcher.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 3c53960ce..1682b21b0 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -710,7 +710,6 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
710 let tt_result = match kind { 710 let tt_result = match kind {
711 "ident" => input 711 "ident" => input
712 .expect_ident() 712 .expect_ident()
713 .and_then(|ident| if ident.text == "_" { Err(()) } else { Ok(ident) })
714 .map(|ident| Some(tt::Leaf::from(ident.clone()).into())) 713 .map(|ident| Some(tt::Leaf::from(ident.clone()).into()))
715 .map_err(|()| err!("expected ident")), 714 .map_err(|()| err!("expected ident")),
716 "tt" => input.expect_tt().map(Some).map_err(|()| err!()), 715 "tt" => input.expect_tt().map(Some).map_err(|()| err!()),
@@ -763,7 +762,7 @@ impl<'a> TtIter<'a> {
763 fn expect_separator(&mut self, separator: &Separator, idx: usize) -> bool { 762 fn expect_separator(&mut self, separator: &Separator, idx: usize) -> bool {
764 let mut fork = self.clone(); 763 let mut fork = self.clone();
765 let ok = match separator { 764 let ok = match separator {
766 Separator::Ident(lhs) if idx == 0 => match fork.expect_ident() { 765 Separator::Ident(lhs) if idx == 0 => match fork.expect_ident_or_underscore() {
767 Ok(rhs) => rhs.text == lhs.text, 766 Ok(rhs) => rhs.text == lhs.text,
768 _ => false, 767 _ => false,
769 }, 768 },
@@ -853,7 +852,7 @@ impl<'a> TtIter<'a> {
853 if punct.char != '\'' { 852 if punct.char != '\'' {
854 return Err(()); 853 return Err(());
855 } 854 }
856 let ident = self.expect_ident()?; 855 let ident = self.expect_ident_or_underscore()?;
857 856
858 Ok(tt::Subtree { 857 Ok(tt::Subtree {
859 delimiter: None, 858 delimiter: None,