about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com>2022-04-04 11:10:40 +0900
committerTakayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com>2022-04-04 11:10:40 +0900
commite0919de0fdfede34fb85f452ddf2754b5768e4f0 (patch)
tree229ee4aafcdca8e7e7e24fe41b15128ca6eb50ca
parent6af09d2505f38e4f1df291df56d497fb2ad935ed (diff)
downloadrust-e0919de0fdfede34fb85f452ddf2754b5768e4f0.tar.gz
rust-e0919de0fdfede34fb85f452ddf2754b5768e4f0.zip
remove unnecessary nested blocks
-rw-r--r--compiler/rustc_resolve/src/late.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index 400adf20cba..11844021c1d 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -2296,22 +2296,18 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
 
         let prev = self.diagnostic_metadata.current_block_could_be_bare_struct_literal.take();
         if let (true, [Stmt { kind: StmtKind::Expr(expr), .. }]) =
-            (block.could_be_bare_literal, &block.stmts[..])
+            (block.could_be_bare_literal, &block.stmts[..]) && let ExprKind::Type(..) = expr.kind
         {
-            if let ExprKind::Type(..) = expr.kind {
-                self.diagnostic_metadata.current_block_could_be_bare_struct_literal =
-                    Some(block.span);
-            }
+            self.diagnostic_metadata.current_block_could_be_bare_struct_literal =
+            Some(block.span);
         }
         // Descend into the block.
         for stmt in &block.stmts {
-            if let StmtKind::Item(ref item) = stmt.kind {
-                if let ItemKind::MacroDef(..) = item.kind {
-                    num_macro_definition_ribs += 1;
-                    let res = self.r.local_def_id(item.id).to_def_id();
-                    self.ribs[ValueNS].push(Rib::new(MacroDefinition(res)));
-                    self.label_ribs.push(Rib::new(MacroDefinition(res)));
-                }
+            if let StmtKind::Item(ref item) = stmt.kind && let ItemKind::MacroDef(..) = item.kind {
+                num_macro_definition_ribs += 1;
+                let res = self.r.local_def_id(item.id).to_def_id();
+                self.ribs[ValueNS].push(Rib::new(MacroDefinition(res)));
+                self.label_ribs.push(Rib::new(MacroDefinition(res)));
             }
 
             self.visit_stmt(stmt);