use if let Some(x) instead of if x.is_some() and x.unwrap() (clippy::unnecessary-unwrap)
This commit is contained in:
parent
966c23f529
commit
c5d654d513
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user