use matches!() macro for simple if let conditions

This commit is contained in:
Matthias Krüger 2020-09-18 19:11:06 +02:00
parent 2c69266c06
commit 40dddd3305
15 changed files with 33 additions and 36 deletions

View file

@ -395,7 +395,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
// so prefixes are prepended with crate root segment if necessary.
// The root is prepended lazily, when the first non-empty prefix or terminating glob
// appears, so imports in braced groups can have roots prepended independently.
let is_glob = if let ast::UseTreeKind::Glob = use_tree.kind { true } else { false };
let is_glob = matches!(use_tree.kind, ast::UseTreeKind::Glob);
let crate_root = match prefix_iter.peek() {
Some(seg) if !seg.ident.is_path_segment_keyword() && seg.ident.span.rust_2015() => {
Some(seg.ident.span.ctxt())

View file

@ -1034,7 +1034,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
let mut add_bindings_for_ns = |ns| {
let parent_rib = self.ribs[ns]
.iter()
.rfind(|r| if let ItemRibKind(_) = r.kind { true } else { false })
.rfind(|r| matches!(r.kind, ItemRibKind(_)))
.expect("associated item outside of an item");
seen_bindings
.extend(parent_rib.bindings.iter().map(|(ident, _)| (*ident, ident.span)));