Skip to content

Commit 966983c

Browse files
committed
simplify
1 parent 8e9ccbf commit 966983c

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

crates/mbe/src/expander/matcher.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
697697
"block" => parser::PrefixEntryPoint::Block,
698698
"meta" => parser::PrefixEntryPoint::MetaItem,
699699
"item" => parser::PrefixEntryPoint::Item,
700+
"vis" => parser::PrefixEntryPoint::Vis,
700701
"expr" => {
701702
return input
702703
.expect_fragment(parser::PrefixEntryPoint::Expr)
@@ -728,8 +729,6 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
728729
})
729730
.map_err(|()| err!())
730731
}
731-
// `vis` is optional
732-
"vis" => Ok(input.expect_fragment(parser::PrefixEntryPoint::Vis).value),
733732
_ => Err(ExpandError::UnexpectedToken),
734733
};
735734
return tt_result.map(|it| it.map(Fragment::Tokens)).into();

crates/mbe/src/tt_iter.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a> TtIter<'a> {
114114
}
115115
}
116116

117-
let mut err = if !cursor.is_root() || error {
117+
let err = if error || !cursor.is_root() {
118118
Some(err!("expected {:?}", entry_point))
119119
} else {
120120
None
@@ -132,9 +132,6 @@ impl<'a> TtIter<'a> {
132132
}
133133
}
134134
self.inner = self.inner.as_slice()[res.len()..].iter();
135-
if res.is_empty() && err.is_none() {
136-
err = Some(err!("no tokens consumed"));
137-
}
138135
let res = match res.len() {
139136
1 => Some(res[0].cloned()),
140137
0 => None,

0 commit comments

Comments
 (0)