Re-format code with new rustfmt

This commit is contained in:
Mark Rousskov 2023-11-13 08:24:55 -05:00
parent db3e2bacb6
commit 917f6540ed
70 changed files with 652 additions and 490 deletions

View file

@ -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 {

View file

@ -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:?}"

View file

@ -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.

View file

@ -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);
}

View file

@ -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)

View file

@ -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);
}