simplify
This commit is contained in:
parent
8e9ccbf97a
commit
966983c707
2 changed files with 2 additions and 6 deletions
|
@ -697,6 +697,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
|
|||
"block" => parser::PrefixEntryPoint::Block,
|
||||
"meta" => parser::PrefixEntryPoint::MetaItem,
|
||||
"item" => parser::PrefixEntryPoint::Item,
|
||||
"vis" => parser::PrefixEntryPoint::Vis,
|
||||
"expr" => {
|
||||
return input
|
||||
.expect_fragment(parser::PrefixEntryPoint::Expr)
|
||||
|
@ -728,8 +729,6 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
|
|||
})
|
||||
.map_err(|()| err!())
|
||||
}
|
||||
// `vis` is optional
|
||||
"vis" => Ok(input.expect_fragment(parser::PrefixEntryPoint::Vis).value),
|
||||
_ => Err(ExpandError::UnexpectedToken),
|
||||
};
|
||||
return tt_result.map(|it| it.map(Fragment::Tokens)).into();
|
||||
|
|
|
@ -114,7 +114,7 @@ impl<'a> TtIter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let mut err = if !cursor.is_root() || error {
|
||||
let err = if error || !cursor.is_root() {
|
||||
Some(err!("expected {:?}", entry_point))
|
||||
} else {
|
||||
None
|
||||
|
@ -132,9 +132,6 @@ impl<'a> TtIter<'a> {
|
|||
}
|
||||
}
|
||||
self.inner = self.inner.as_slice()[res.len()..].iter();
|
||||
if res.is_empty() && err.is_none() {
|
||||
err = Some(err!("no tokens consumed"));
|
||||
}
|
||||
let res = match res.len() {
|
||||
1 => Some(res[0].cloned()),
|
||||
0 => None,
|
||||
|
|
Loading…
Add table
Reference in a new issue