From c5d654d5132b702d028ed00b5ec5c654a0b4a2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Mar 2021 01:39:58 +0100 Subject: use if let Some(x) instead of if x.is_some() and x.unwrap() (clippy::unnecessary-unwrap) --- crates/mbe/src/expander/matcher.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/mbe/src/expander') diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index 1bf7c2e81..b6782b4ba 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs @@ -540,7 +540,7 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match { let mut src = TtIter::new(src); let mut stack: SmallVec<[TtIter; 1]> = SmallVec::new(); let mut res = Match::default(); - let mut error_reover_item = None; + let mut error_recover_item = None; let mut bindings_builder = BindingsBuilder::default(); @@ -579,9 +579,9 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match { stdx::always!(cur_items.is_empty()); if error_items.len() > 0 { - error_reover_item = error_items.pop().map(|it| it.bindings); + error_recover_item = error_items.pop().map(|it| it.bindings); } else if eof_items.len() > 0 { - error_reover_item = Some(eof_items[0].bindings.clone()); + error_recover_item = Some(eof_items[0].bindings.clone()); } // We need to do some post processing after the `match_loop_inner`. @@ -594,8 +594,8 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match { res.bindings = bindings_builder.build(&eof_items[0].bindings); } else { // Error recovery - if error_reover_item.is_some() { - res.bindings = bindings_builder.build(&error_reover_item.unwrap()); + if let Some(item) = error_recover_item { + res.bindings = bindings_builder.build(&item); } res.add_err(ExpandError::UnexpectedToken); } @@ -618,7 +618,7 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match { } res.add_err(err!("leftover tokens")); - if let Some(error_reover_item) = error_reover_item { + if let Some(error_reover_item) = error_recover_item { res.bindings = bindings_builder.build(&error_reover_item); } return res; -- cgit v1.2.3