]> git.lizzy.rs Git - rust.git/commitdiff
simplify
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 27 Dec 2021 11:58:24 +0000 (14:58 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 28 Dec 2021 14:00:55 +0000 (17:00 +0300)
crates/mbe/src/expander/matcher.rs

index b2d3f038f544a558d04d239a88cd1a7886fac6b0..8d192b53f85e510eeab6b1decf4d439daaca1007 100644 (file)
@@ -726,10 +726,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
                         .map_err(|()| err!())
                 }
                 // `vis` is optional
-                "vis" => match input.eat_vis() {
-                    Some(vis) => Ok(Some(vis)),
-                    None => Ok(None),
-                },
+                "vis" => Ok(input.eat_vis()),
                 _ => Err(ExpandError::UnexpectedToken),
             };
             return tt_result.map(|it| it.map(Fragment::Tokens)).into();
@@ -899,14 +896,7 @@ fn expect_lifetime(&mut self) -> Result<tt::TokenTree, ()> {
     }
 
     fn eat_vis(&mut self) -> Option<tt::TokenTree> {
-        let mut fork = self.clone();
-        match fork.expect_fragment(Visibility) {
-            ExpandResult { value: tt, err: None } => {
-                *self = fork;
-                tt
-            }
-            ExpandResult { value: _, err: Some(_) } => None,
-        }
+        self.expect_fragment(Visibility).value
     }
 
     fn eat_char(&mut self, c: char) -> Option<tt::TokenTree> {