Skip to content

Commit bdbf545

Browse files
committed
interpret: less debug-printing of types
1 parent da08a3f commit bdbf545

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
8787
let fn_ptr = self.fn_ptr(FnVal::Instance(instance));
8888
self.write_pointer(fn_ptr, dest)?;
8989
}
90-
_ => span_bug!(self.cur_span(), "reify fn pointer on {:?}", src.layout.ty),
90+
_ => span_bug!(self.cur_span(), "reify fn pointer on {}", src.layout.ty),
9191
}
9292
}
9393

@@ -98,7 +98,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9898
// No change to value
9999
self.write_immediate(*src, dest)?;
100100
}
101-
_ => span_bug!(self.cur_span(), "fn to unsafe fn cast on {:?}", cast_ty),
101+
_ => span_bug!(self.cur_span(), "fn to unsafe fn cast on {}", cast_ty),
102102
}
103103
}
104104

@@ -119,7 +119,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
119119
let fn_ptr = self.fn_ptr(FnVal::Instance(instance));
120120
self.write_pointer(fn_ptr, dest)?;
121121
}
122-
_ => span_bug!(self.cur_span(), "closure fn pointer on {:?}", src.layout.ty),
122+
_ => span_bug!(self.cur_span(), "closure fn pointer on {}", src.layout.ty),
123123
}
124124
}
125125

@@ -190,7 +190,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
190190
Float(FloatTy::F32) => self.cast_from_float(src.to_scalar().to_f32()?, cast_ty),
191191
Float(FloatTy::F64) => self.cast_from_float(src.to_scalar().to_f64()?, cast_ty),
192192
_ => {
193-
bug!("Can't cast 'Float' type into {:?}", cast_ty);
193+
bug!("Can't cast 'Float' type into {}", cast_ty);
194194
}
195195
};
196196
Ok(ImmTy::from_scalar(val, layout))
@@ -218,7 +218,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
218218
Immediate::ScalarPair(data, _) => Ok(ImmTy::from_scalar(data, dest_layout)),
219219
Immediate::Scalar(..) => span_bug!(
220220
self.cur_span(),
221-
"{:?} input to a fat-to-thin cast ({:?} -> {:?})",
221+
"{:?} input to a fat-to-thin cast ({} -> {})",
222222
*src,
223223
src.layout.ty,
224224
cast_ty
@@ -302,7 +302,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
302302
}
303303

304304
// Casts to bool are not permitted by rustc, no need to handle them here.
305-
_ => span_bug!(self.cur_span(), "invalid int to {:?} cast", cast_ty),
305+
_ => span_bug!(self.cur_span(), "invalid int to {} cast", cast_ty),
306306
})
307307
}
308308

@@ -335,7 +335,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
335335
// float -> f64
336336
Float(FloatTy::F64) => Scalar::from_f64(f.convert(&mut false).value),
337337
// That's it.
338-
_ => span_bug!(self.cur_span(), "invalid float to {:?} cast", dest_ty),
338+
_ => span_bug!(self.cur_span(), "invalid float to {} cast", dest_ty),
339339
}
340340
}
341341

@@ -393,7 +393,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
393393

394394
span_bug!(
395395
self.cur_span(),
396-
"invalid pointer unsizing {:?} -> {:?}",
396+
"invalid pointer unsizing {} -> {}",
397397
src.layout.ty,
398398
cast_ty
399399
)
@@ -407,7 +407,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
407407
cast_ty: TyAndLayout<'tcx>,
408408
dest: &PlaceTy<'tcx, M::Provenance>,
409409
) -> InterpResult<'tcx> {
410-
trace!("Unsizing {:?} of type {} into {:?}", *src, src.layout.ty, cast_ty.ty);
410+
trace!("Unsizing {:?} of type {} into {}", *src, src.layout.ty, cast_ty.ty);
411411
match (&src.layout.ty.kind(), &cast_ty.ty.kind()) {
412412
(&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(TypeAndMut { ty: c, .. }))
413413
| (&ty::RawPtr(TypeAndMut { ty: s, .. }), &ty::RawPtr(TypeAndMut { ty: c, .. })) => {

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub(super) fn from_known_layout<'tcx>(
416416
if !mir_assign_valid_types(tcx.tcx, param_env, check_layout, known_layout) {
417417
span_bug!(
418418
tcx.span,
419-
"expected type differs from actual type.\nexpected: {:?}\nactual: {:?}",
419+
"expected type differs from actual type.\nexpected: {}\nactual: {}",
420420
known_layout.ty,
421421
check_layout.ty,
422422
);
@@ -712,7 +712,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
712712

713713
ty::Foreign(_) => Ok(None),
714714

715-
_ => span_bug!(self.cur_span(), "size_and_align_of::<{:?}> not supported", layout.ty),
715+
_ => span_bug!(self.cur_span(), "size_and_align_of::<{}> not supported", layout.ty),
716716
}
717717
}
718718
#[inline]
@@ -982,7 +982,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
982982

983983
ty::Bound(..)
984984
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
985-
bug!("`is_very_trivially_sized` applied to unexpected type: {:?}", ty)
985+
bug!("`is_very_trivially_sized` applied to unexpected type: {}", ty)
986986
}
987987
}
988988
}

compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
514514
Abi::Scalar(abi::Scalar::Initialized { .. })
515515
| Abi::ScalarPair(abi::Scalar::Initialized { .. }, abi::Scalar::Initialized { .. })
516516
) {
517-
span_bug!(
518-
self.cur_span(),
519-
"primitive read not possible for type: {:?}",
520-
op.layout().ty
521-
);
517+
span_bug!(self.cur_span(), "primitive read not possible for type: {}", op.layout().ty);
522518
}
523519
let imm = self.read_immediate_raw(op)?.right().unwrap();
524520
if matches!(*imm, Immediate::Uninit) {
@@ -669,7 +665,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
669665
)?)?,
670666
op.layout,
671667
),
672-
"eval_place of a MIR place with type {:?} produced an interpreter operand with type {:?}",
668+
"eval_place of a MIR place with type {:?} produced an interpreter operand with type {}",
673669
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
674670
op.layout.ty,
675671
);

compiler/rustc_const_eval/src/interpret/operator.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
207207
if left_layout.ty != right_layout.ty {
208208
span_bug!(
209209
self.cur_span(),
210-
"invalid asymmetric binary op {:?}: {:?} ({:?}), {:?} ({:?})",
211-
bin_op,
212-
l,
213-
left_layout.ty,
214-
r,
215-
right_layout.ty,
210+
"invalid asymmetric binary op {bin_op:?}: {l:?} ({l_ty}), {r:?} ({r_ty})",
211+
l_ty = left_layout.ty,
212+
r_ty = right_layout.ty,
216213
)
217214
}
218215

@@ -309,7 +306,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
309306

310307
_ => span_bug!(
311308
self.cur_span(),
312-
"invalid binary op {:?}: {:?}, {:?} (both {:?})",
309+
"invalid binary op {:?}: {:?}, {:?} (both {})",
313310
bin_op,
314311
l,
315312
r,
@@ -355,7 +352,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
355352
right: &ImmTy<'tcx, M::Provenance>,
356353
) -> InterpResult<'tcx, (ImmTy<'tcx, M::Provenance>, bool)> {
357354
trace!(
358-
"Running binary op {:?}: {:?} ({:?}), {:?} ({:?})",
355+
"Running binary op {:?}: {:?} ({}), {:?} ({})",
359356
bin_op,
360357
*left,
361358
left.layout.ty,
@@ -394,7 +391,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
394391
// the RHS type can be different, e.g. for shifts -- but it has to be integral, too
395392
assert!(
396393
right.layout.ty.is_integral(),
397-
"Unexpected types for BinOp: {:?} {:?} {:?}",
394+
"Unexpected types for BinOp: {} {:?} {}",
398395
left.layout.ty,
399396
bin_op,
400397
right.layout.ty
@@ -409,7 +406,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
409406
// (Even when both sides are pointers, their type might differ, see issue #91636)
410407
assert!(
411408
right.layout.ty.is_any_ptr() || right.layout.ty.is_integral(),
412-
"Unexpected types for BinOp: {:?} {:?} {:?}",
409+
"Unexpected types for BinOp: {} {:?} {}",
413410
left.layout.ty,
414411
bin_op,
415412
right.layout.ty
@@ -419,7 +416,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
419416
}
420417
_ => span_bug!(
421418
self.cur_span(),
422-
"Invalid MIR: bad LHS type for binop: {:?}",
419+
"Invalid MIR: bad LHS type for binop: {}",
423420
left.layout.ty
424421
),
425422
}
@@ -447,7 +444,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
447444

448445
let layout = val.layout;
449446
let val = val.to_scalar();
450-
trace!("Running unary op {:?}: {:?} ({:?})", un_op, val, layout.ty);
447+
trace!("Running unary op {:?}: {:?} ({})", un_op, val, layout.ty);
451448

452449
match layout.ty.kind() {
453450
ty::Bool => {

compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ where
460460
trace!("deref to {} on {:?}", val.layout.ty, *val);
461461

462462
if val.layout.ty.is_box() {
463-
bug!("dereferencing {:?}", val.layout.ty);
463+
bug!("dereferencing {}", val.layout.ty);
464464
}
465465

466466
let mplace = self.ref_to_mplace(&val)?;
@@ -582,7 +582,7 @@ where
582582
)?)?,
583583
place.layout,
584584
),
585-
"eval_place of a MIR place with type {:?} produced an interpreter place with type {:?}",
585+
"eval_place of a MIR place with type {:?} produced an interpreter place with type {}",
586586
mir_place.ty(&self.frame().body.local_decls, *self.tcx).ty,
587587
place.layout.ty,
588588
);
@@ -835,7 +835,7 @@ where
835835
if !allow_transmute && !layout_compat {
836836
span_bug!(
837837
self.cur_span(),
838-
"type mismatch when copying!\nsrc: {:?},\ndest: {:?}",
838+
"type mismatch when copying!\nsrc: {},\ndest: {}",
839839
src.layout().ty,
840840
dest.layout().ty,
841841
);

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
149149
}
150150
_ => span_bug!(
151151
terminator.source_info.span,
152-
"invalid callee of type {:?}",
152+
"invalid callee of type {}",
153153
func.layout.ty
154154
),
155155
};
@@ -679,10 +679,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
679679
self.storage_live(local)?;
680680
// Must be a tuple
681681
let ty::Tuple(fields) = ty.kind() else {
682-
span_bug!(
683-
self.cur_span(),
684-
"non-tuple type for `spread_arg`: {ty:?}"
685-
)
682+
span_bug!(self.cur_span(), "non-tuple type for `spread_arg`: {ty}")
686683
};
687684
for (i, field_ty) in fields.iter().enumerate() {
688685
let dest = dest.project_deeper(
@@ -924,7 +921,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
924921
target: mir::BasicBlock,
925922
unwind: mir::UnwindAction,
926923
) -> InterpResult<'tcx> {
927-
trace!("drop_in_place: {:?},\n {:?}, {:?}", *place, place.layout.ty, instance);
924+
trace!("drop_in_place: {:?},\n instance={:?}", place, instance);
928925
// We take the address of the object. This may well be unaligned, which is fine
929926
// for us here. However, unaligned accesses will probably make the actual drop
930927
// implementation fail -- a problem shared by rustc.

0 commit comments

Comments
 (0)