From e0919de0fdfede34fb85f452ddf2754b5768e4f0 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com> Date: Mon, 4 Apr 2022 11:10:40 +0900 Subject: [PATCH 1/2] remove unnecessary nested blocks --- compiler/rustc_resolve/src/late.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 400adf20cba7c..11844021c1d1b 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); From a56f21466e09a247e33660d4745963faba56654e Mon Sep 17 00:00:00 2001 From: Takayuki Maeda <41065217+TaKO8Ki@users.noreply.github.com> Date: Mon, 4 Apr 2022 12:49:02 +0900 Subject: [PATCH 2/2] format cond --- compiler/rustc_resolve/src/late.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 11844021c1d1b..6fedabc816cff 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2296,14 +2296,16 @@ 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[..]) && let ExprKind::Type(..) = expr.kind + (block.could_be_bare_literal, &block.stmts[..]) + && let ExprKind::Type(..) = expr.kind { 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 && let ItemKind::MacroDef(..) = item.kind { + 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)));