diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2023-11-13 08:24:55 -0500 | 
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2023-11-15 21:45:48 -0500 | 
| commit | 917f6540edc20de22e1fb3069e7b325209109350 (patch) | |
| tree | a5a01f5b18db8bd67675a4c1f6a98867333aad96 /compiler/rustc_mir_transform/src | |
| parent | db3e2bacb69c068fd9262a3aadd961ea2f7f940e (diff) | |
| download | rust-917f6540edc20de22e1fb3069e7b325209109350.tar.gz rust-917f6540edc20de22e1fb3069e7b325209109350.zip | |
Re-format code with new rustfmt
Diffstat (limited to 'compiler/rustc_mir_transform/src')
6 files changed, 28 insertions, 12 deletions
| diff --git a/compiler/rustc_mir_transform/src/cost_checker.rs b/compiler/rustc_mir_transform/src/cost_checker.rs index 9bb26693cb2..79bed960b95 100644 --- a/compiler/rustc_mir_transform/src/cost_checker.rs +++ b/compiler/rustc_mir_transform/src/cost_checker.rs @@ -69,7 +69,9 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { } TerminatorKind::Call { func: Operand::Constant(ref f), unwind, .. } => { let fn_ty = self.instantiate_ty(f.const_.ty()); - self.cost += if let ty::FnDef(def_id, _) = *fn_ty.kind() && tcx.is_intrinsic(def_id) { + self.cost += if let ty::FnDef(def_id, _) = *fn_ty.kind() + && tcx.is_intrinsic(def_id) + { // Don't give intrinsics the extra penalty for calls INSTR_COST } else { diff --git a/compiler/rustc_mir_transform/src/coverage/counters.rs b/compiler/rustc_mir_transform/src/coverage/counters.rs index b34ec95b4e8..1bc3c25c653 100644 --- a/compiler/rustc_mir_transform/src/coverage/counters.rs +++ b/compiler/rustc_mir_transform/src/coverage/counters.rs @@ -138,7 +138,9 @@ impl CoverageCounters { // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also // have an expression (to be injected into an existing `BasicBlock` represented by this // `BasicCoverageBlock`). - if let Some(node_counter) = self.bcb_counter(to_bcb) && !node_counter.is_expression() { + if let Some(node_counter) = self.bcb_counter(to_bcb) + && !node_counter.is_expression() + { bug!( "attempt to add an incoming edge counter from {from_bcb:?} \ when the target BCB already has {node_counter:?}" diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index b318134ae67..e0abb5da047 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -475,7 +475,9 @@ impl<'a> CoverageSpansGenerator<'a> { } while let Some(curr) = self.sorted_spans_iter.next() { debug!("FOR curr={:?}", curr); - if let Some(prev) = &self.some_prev && prev.span.lo() > curr.span.lo() { + if let Some(prev) = &self.some_prev + && prev.span.lo() > curr.span.lo() + { // Skip curr because prev has already advanced beyond the end of curr. // This can only happen if a prior iteration updated `prev` to skip past // a region of code, such as skipping past a closure. diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 81d2bba989a..bb2a90a06da 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -597,7 +597,9 @@ fn propagatable_scalar( state: &State<FlatSet<Scalar>>, map: &Map, ) -> Option<Scalar> { - if let FlatSet::Elem(value) = state.get_idx(place, map) && value.try_to_int().is_ok() { + if let FlatSet::Elem(value) = state.get_idx(place, map) + && value.try_to_int().is_ok() + { // Do not attempt to propagate pointers, as we may fail to preserve their identity. Some(value) } else { @@ -836,7 +838,8 @@ impl<'tcx> Visitor<'tcx> for OperandCollector<'tcx, '_, '_, '_> { location: Location, ) { if let PlaceElem::Index(local) = elem - && let Some(value) = self.visitor.try_make_constant(self.ecx, local.into(), self.state, self.map) + && let Some(value) = + self.visitor.try_make_constant(self.ecx, local.into(), self.state, self.map) { self.visitor.patch.before_effect.insert((location, local.into()), value); } diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index dce298e92e1..98a03618286 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -461,7 +461,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { } NullaryOp(null_op, ty) => { let layout = self.ecx.layout_of(ty).ok()?; - if let NullOp::SizeOf | NullOp::AlignOf = null_op && layout.is_unsized() { + if let NullOp::SizeOf | NullOp::AlignOf = null_op + && layout.is_unsized() + { return None; } let val = match null_op { @@ -865,7 +867,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { .collect(); let fields = fields?; - if let AggregateTy::Array = ty && fields.len() > 4 { + if let AggregateTy::Array = ty + && fields.len() > 4 + { let first = fields[0]; if fields.iter().all(|&v| v == first) { let len = ty::Const::from_target_usize(self.tcx, fields.len().try_into().unwrap()); @@ -1008,8 +1012,7 @@ impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> { // Do not try to simplify a constant, it's already in canonical shape. && !matches!(rvalue, Rvalue::Use(Operand::Constant(_))) { - if let Some(value) = self.simplify_rvalue(rvalue, location) - { + if let Some(value) = self.simplify_rvalue(rvalue, location) { if let Some(const_) = self.try_as_constant(value) { *rvalue = Rvalue::Use(Operand::Constant(Box::new(const_))); } else if let Some(local) = self.try_as_local(value, location) diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 7b918be4474..22300ad24be 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -247,7 +247,9 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { let last_non_rec = self.opportunities.len(); let predecessors = &self.body.basic_blocks.predecessors()[bb]; - if let &[pred] = &predecessors[..] && bb != START_BLOCK { + if let &[pred] = &predecessors[..] + && bb != START_BLOCK + { let term = self.body.basic_blocks[pred].terminator(); match term.kind { TerminatorKind::SwitchInt { ref discr, ref targets } => { @@ -419,8 +421,10 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { // Do not support unions. AggregateKind::Adt(.., Some(_)) => return None, AggregateKind::Adt(_, variant_index, ..) if agg_ty.is_enum() => { - if let Some(discr_target) = self.map.apply(lhs, TrackElem::Discriminant) - && let Some(discr_value) = discriminant_for_variant(agg_ty, *variant_index) + if let Some(discr_target) = + self.map.apply(lhs, TrackElem::Discriminant) + && let Some(discr_value) = + discriminant_for_variant(agg_ty, *variant_index) { self.process_operand(bb, discr_target, &discr_value, state); } | 
