Rollup merge of #95631 - TaKO8Ki:remove-unnecessary-nested-blocks, r=davidtwco

Refactor: remove unnecessary nested blocks
This commit is contained in:
Dylan DPC 2022-04-05 01:53:35 +02:00 committed by GitHub
commit 5b8ac2d1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2297,21 +2297,19 @@ fn resolve_block(&mut self, block: &'ast Block) {
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
{
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);