Skip to content

Commit dbc29a0

Browse files
committed
Run fmt
1 parent c77433c commit dbc29a0

File tree

11 files changed

+82
-57
lines changed

11 files changed

+82
-57
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,11 +1372,14 @@ pub fn noop_flat_map_stmt<T: MutVisitor>(
13721372
Stmt { kind, span }: Stmt,
13731373
vis: &mut T,
13741374
) -> SmallVec<[Stmt; 1]> {
1375-
let res = noop_flat_map_stmt_kind(kind, vis).into_iter().map(|kind| {
1376-
let mut new_span = span;
1377-
vis.visit_span(&mut new_span);
1378-
Stmt { kind, span: new_span }
1379-
}).collect();
1375+
let res = noop_flat_map_stmt_kind(kind, vis)
1376+
.into_iter()
1377+
.map(|kind| {
1378+
let mut new_span = span;
1379+
vis.visit_span(&mut new_span);
1380+
Stmt { kind, span: new_span }
1381+
})
1382+
.collect();
13801383
tracing::info!("Made new statements: {:?}", res);
13811384
res
13821385
}
@@ -1396,7 +1399,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
13961399
StmtKind::Empty { mut id } => {
13971400
vis.visit_id(&mut id);
13981401
smallvec![StmtKind::Empty { id }]
1399-
},
1402+
}
14001403
StmtKind::MacCall(mut mac) => {
14011404
let MacCallStmt { mac: mac_, style: _, attrs, tokens, id } = mac.deref_mut();
14021405
vis.visit_id(id);

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,9 +2427,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24272427
return self
24282428
.lower_item_id(it)
24292429
.into_iter()
2430-
.map(|item_id| {
2431-
hir::Stmt { kind: hir::StmtKind::Item(item_id), span: s.span }
2432-
})
2430+
.map(|item_id| hir::Stmt { kind: hir::StmtKind::Item(item_id), span: s.span })
24332431
.collect();
24342432
}
24352433
StmtKind::Expr(ref e) => {

compiler/rustc_expand/src/base.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,7 @@ where
337337
// Use a macro because forwarding to a simple function has type system issues
338338
macro_rules! make_stmts_default {
339339
($me:expr) => {
340-
$me.make_expr().map(|e| {
341-
smallvec![ast::Stmt {
342-
span: e.span,
343-
kind: ast::StmtKind::Expr(e),
344-
}]
345-
})
340+
$me.make_expr().map(|e| smallvec![ast::Stmt { span: e.span, kind: ast::StmtKind::Expr(e) }])
346341
};
347342
}
348343

compiler/rustc_expand/src/build.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,7 @@ impl<'a> ExtCtxt<'a> {
181181
}
182182

183183
pub fn block_expr(&self, expr: P<ast::Expr>) -> P<ast::Block> {
184-
self.block(
185-
expr.span,
186-
vec![ast::Stmt {
187-
span: expr.span,
188-
kind: ast::StmtKind::Expr(expr),
189-
}],
190-
)
184+
self.block(expr.span, vec![ast::Stmt { span: expr.span, kind: ast::StmtKind::Expr(expr) }])
191185
}
192186
pub fn block(&self, span: Span, stmts: Vec<ast::Stmt>) -> P<ast::Block> {
193187
P(ast::Block {

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ use rustc_ast::{MacCallStmt, MacStmtStyle, MetaItemKind, ModKind, NestedMetaItem
1717
use rustc_ast::{NodeId, PatKind, Path, StmtKind, Unsafe};
1818
use rustc_ast_pretty::pprust;
1919
use rustc_attr::is_builtin_attr;
20+
use rustc_data_structures::fx::FxHashSet;
2021
use rustc_data_structures::map_in_place::MapInPlace;
2122
use rustc_data_structures::stack::ensure_sufficient_stack;
2223
use rustc_data_structures::sync::Lrc;
23-
use rustc_data_structures::fx::FxHashSet;
2424
use rustc_errors::{Applicability, FatalError, PResult};
2525
use rustc_feature::Features;
2626
use rustc_parse::parser::{

compiler/rustc_interface/src/util.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
822822
tokens: None,
823823
});
824824

825-
ast::Stmt {
826-
kind: ast::StmtKind::Expr(expr),
827-
span: rustc_span::DUMMY_SP,
828-
}
825+
ast::Stmt { kind: ast::StmtKind::Expr(expr), span: rustc_span::DUMMY_SP }
829826
}
830827

831828
let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.resolver);
@@ -837,10 +834,8 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
837834
tokens: None,
838835
});
839836

840-
let loop_stmt = ast::Stmt {
841-
span: rustc_span::DUMMY_SP,
842-
kind: ast::StmtKind::Expr(loop_expr),
843-
};
837+
let loop_stmt =
838+
ast::Stmt { span: rustc_span::DUMMY_SP, kind: ast::StmtKind::Expr(loop_expr) };
844839

845840
if self.within_static_or_const {
846841
noop_visit_block(b, self)

compiler/rustc_middle/src/middle/region.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ impl fmt::Debug for Scope {
9494
ScopeData::Node => write!(fmt, "Node({:?}, {:?})", self.id, self.for_stmt),
9595
ScopeData::CallSite => write!(fmt, "CallSite({:?}. {:?})", self.id, self.for_stmt),
9696
ScopeData::Arguments => write!(fmt, "Arguments({:?}, {:?})", self.id, self.for_stmt),
97-
ScopeData::Destruction => write!(fmt, "Destruction({:?}, {:?})", self.id, self.for_stmt),
97+
ScopeData::Destruction => {
98+
write!(fmt, "Destruction({:?}, {:?})", self.id, self.for_stmt)
99+
}
98100
ScopeData::Remainder(fsi) => write!(
99101
fmt,
100102
"Remainder {{ block: {:?}, first_statement_index: {}, for_stmt: {:?}}}",
@@ -175,11 +177,7 @@ impl Scope {
175177
Some(hir_id) => hir_id,
176178
None => return DUMMY_SP,
177179
};
178-
let span = if self.for_stmt {
179-
tcx.hir().stmt_span(hir_id)
180-
} else {
181-
tcx.hir().span(hir_id)
182-
};
180+
let span = if self.for_stmt { tcx.hir().stmt_span(hir_id) } else { tcx.hir().span(hir_id) };
183181

184182
if let ScopeData::Remainder(first_statement_index) = self.data {
185183
if let Node::Block(ref blk) = tcx.hir().get(hir_id) {
@@ -343,7 +341,10 @@ impl ScopeTree {
343341

344342
// Record the destruction scopes for later so we can query them.
345343
if let ScopeData::Destruction = child.data {
346-
assert_eq!(self.destruction_scopes.insert((child.item_local_id(), child.for_stmt), child), None);
344+
assert_eq!(
345+
self.destruction_scopes.insert((child.item_local_id(), child.for_stmt), child),
346+
None
347+
);
347348
}
348349
}
349350

compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,16 @@ where
624624
body.generator_kind,
625625
);
626626

627-
let call_site_scope =
628-
region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite, for_stmt: false };
629-
let arg_scope =
630-
region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::Arguments, for_stmt: false };
627+
let call_site_scope = region::Scope {
628+
id: body.value.hir_id.local_id,
629+
data: region::ScopeData::CallSite,
630+
for_stmt: false,
631+
};
632+
let arg_scope = region::Scope {
633+
id: body.value.hir_id.local_id,
634+
data: region::ScopeData::Arguments,
635+
for_stmt: false,
636+
};
631637
let source_info = builder.source_info(span);
632638
let call_site_s = (call_site_scope, source_info);
633639
unpack!(builder.in_scope(call_site_s, LintLevel::Inherited, |builder| {

compiler/rustc_mir_build/src/thir/cx/block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ impl<'tcx> Cx<'tcx> {
4747
.enumerate()
4848
.filter_map(|(index, stmt)| {
4949
let hir_id = stmt.kind.hir_id();
50-
let opt_dxn_ext = self.region_scope_tree.opt_destruction_scope(hir_id.local_id, true);
50+
let opt_dxn_ext =
51+
self.region_scope_tree.opt_destruction_scope(hir_id.local_id, true);
5152
match stmt.kind {
5253
hir::StmtKind::Expr(ref expr) | hir::StmtKind::Semi(ref expr) => {
5354
let stmt = Stmt {

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ impl<'tcx> Cx<'tcx> {
3232

3333
pub(super) fn mirror_expr_inner(&mut self, hir_expr: &'tcx hir::Expr<'tcx>) -> ExprId {
3434
let temp_lifetime = self.region_scope_tree.temporary_scope(hir_expr.hir_id.local_id, false);
35-
let expr_scope =
36-
region::Scope { id: hir_expr.hir_id.local_id, data: region::ScopeData::Node, for_stmt: false };
35+
let expr_scope = region::Scope {
36+
id: hir_expr.hir_id.local_id,
37+
data: region::ScopeData::Node,
38+
for_stmt: false,
39+
};
3740

3841
debug!("Expr::make_mirror(): id={}, span={:?}", hir_expr.hir_id, hir_expr.span);
3942

@@ -498,8 +501,9 @@ impl<'tcx> Cx<'tcx> {
498501
expr.kind
499502
),
500503
};
501-
let temp_lifetime =
502-
self.region_scope_tree.temporary_scope(expr.hir_id.local_id, false);
504+
let temp_lifetime = self
505+
.region_scope_tree
506+
.temporary_scope(expr.hir_id.local_id, false);
503507
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
504508
let ty;
505509
match res {
@@ -579,14 +583,22 @@ impl<'tcx> Cx<'tcx> {
579583
}
580584
hir::ExprKind::Break(dest, ref value) => match dest.target_id {
581585
Ok(target_id) => ExprKind::Break {
582-
label: region::Scope { id: target_id.local_id, data: region::ScopeData::Node, for_stmt: false, },
586+
label: region::Scope {
587+
id: target_id.local_id,
588+
data: region::ScopeData::Node,
589+
for_stmt: false,
590+
},
583591
value: value.as_ref().map(|value| self.mirror_expr(value)),
584592
},
585593
Err(err) => bug!("invalid loop id for break: {}", err),
586594
},
587595
hir::ExprKind::Continue(dest) => match dest.target_id {
588596
Ok(loop_id) => ExprKind::Continue {
589-
label: region::Scope { id: loop_id.local_id, data: region::ScopeData::Node, for_stmt: false, },
597+
label: region::Scope {
598+
id: loop_id.local_id,
599+
data: region::ScopeData::Node,
600+
for_stmt: false,
601+
},
590602
},
591603
Err(err) => bug!("invalid loop id for continue: {}", err),
592604
},
@@ -601,7 +613,8 @@ impl<'tcx> Cx<'tcx> {
601613
},
602614
hir::ExprKind::Loop(ref body, ..) => {
603615
let block_ty = self.typeck_results().node_type(body.hir_id);
604-
let temp_lifetime = self.region_scope_tree.temporary_scope(body.hir_id.local_id, false);
616+
let temp_lifetime =
617+
self.region_scope_tree.temporary_scope(body.hir_id.local_id, false);
605618
let block = self.mirror_block(body);
606619
let body = self.thir.exprs.push(Expr {
607620
ty: block_ty,
@@ -837,7 +850,11 @@ impl<'tcx> Cx<'tcx> {
837850
}),
838851
body: self.mirror_expr(arm.body),
839852
lint_level: LintLevel::Explicit(arm.hir_id),
840-
scope: region::Scope { id: arm.hir_id.local_id, data: region::ScopeData::Node, for_stmt: false },
853+
scope: region::Scope {
854+
id: arm.hir_id.local_id,
855+
data: region::ScopeData::Node,
856+
for_stmt: false,
857+
},
841858
span: arm.span,
842859
};
843860
self.thir.arms.push(arm)
@@ -922,7 +939,8 @@ impl<'tcx> Cx<'tcx> {
922939
// a constant reference (or constant raw pointer for `static mut`) in MIR
923940
Res::Def(DefKind::Static, id) => {
924941
let ty = self.tcx.static_ptr_ty(id);
925-
let temp_lifetime = self.region_scope_tree.temporary_scope(expr.hir_id.local_id, false);
942+
let temp_lifetime =
943+
self.region_scope_tree.temporary_scope(expr.hir_id.local_id, false);
926944
let kind = if self.tcx.is_thread_local_static(id) {
927945
ExprKind::ThreadLocalRef(id)
928946
} else {
@@ -1026,7 +1044,8 @@ impl<'tcx> Cx<'tcx> {
10261044
closure_expr: &'tcx hir::Expr<'tcx>,
10271045
place: HirPlace<'tcx>,
10281046
) -> Expr<'tcx> {
1029-
let temp_lifetime = self.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id, false);
1047+
let temp_lifetime =
1048+
self.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id, false);
10301049
let var_ty = place.base_ty;
10311050

10321051
// The result of capture analysis in `rustc_typeck/check/upvar.rs`represents a captured path
@@ -1081,7 +1100,8 @@ impl<'tcx> Cx<'tcx> {
10811100
let upvar_capture = captured_place.info.capture_kind;
10821101
let captured_place_expr =
10831102
self.convert_captured_hir_place(closure_expr, captured_place.place.clone());
1084-
let temp_lifetime = self.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id, false);
1103+
let temp_lifetime =
1104+
self.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id, false);
10851105

10861106
match upvar_capture {
10871107
ty::UpvarCapture::ByValue(_) => captured_place_expr,

compiler/rustc_passes/src/region.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ fn resolve_arm<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, arm: &'tcx hir
169169
}
170170

171171
fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir::Pat<'tcx>) {
172-
visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node, for_stmt: false });
172+
visitor.record_child_scope(Scope {
173+
id: pat.hir_id.local_id,
174+
data: ScopeData::Node,
175+
for_stmt: false,
176+
});
173177

174178
// If this is a binding then record the lifetime of that binding.
175179
if let PatKind::Binding(..) = pat.kind {
@@ -743,8 +747,16 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
743747
let outer_pessimistic_yield = mem::replace(&mut self.pessimistic_yield, false);
744748
self.terminating_scopes.insert((body.value.hir_id.local_id, false));
745749

746-
self.enter_scope(Scope { id: body.value.hir_id.local_id, data: ScopeData::CallSite, for_stmt: false });
747-
self.enter_scope(Scope { id: body.value.hir_id.local_id, data: ScopeData::Arguments, for_stmt: false });
750+
self.enter_scope(Scope {
751+
id: body.value.hir_id.local_id,
752+
data: ScopeData::CallSite,
753+
for_stmt: false,
754+
});
755+
self.enter_scope(Scope {
756+
id: body.value.hir_id.local_id,
757+
data: ScopeData::Arguments,
758+
for_stmt: false,
759+
});
748760

749761
// The arguments and `self` are parented to the fn.
750762
self.cx.var_parent = self.cx.parent.take();

0 commit comments

Comments
 (0)