Skip to content

Commit 3087b63

Browse files
authored
Rollup merge of #117373 - saethlin:avoid-ice-lint, r=compiler-errors
Avoid the path trimming ICE lint in error reporting Types or really anything in MIR should never be formatted without path trimming disabled, because its formatting often tries to construct trimmed paths. In this case, the lint turns a nice error report into an irrelevant ICE.
2 parents 2b2360a + 88f0688 commit 3087b63

File tree

1 file changed

+4
-8
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+4
-8
lines changed

compiler/rustc_const_eval/src/interpret/cast.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
145145
assert!(dest.layout.is_sized());
146146
assert_eq!(cast_ty, dest.layout.ty); // we otherwise ignore `cast_ty` enirely...
147147
if src.layout.size != dest.layout.size {
148-
let src_bytes = src.layout.size.bytes();
149-
let dest_bytes = dest.layout.size.bytes();
150-
let src_ty = format!("{}", src.layout.ty);
151-
let dest_ty = format!("{}", dest.layout.ty);
152148
throw_ub_custom!(
153149
fluent::const_eval_invalid_transmute,
154-
src_bytes = src_bytes,
155-
dest_bytes = dest_bytes,
156-
src = src_ty,
157-
dest = dest_ty,
150+
src_bytes = src.layout.size.bytes(),
151+
dest_bytes = dest.layout.size.bytes(),
152+
src = src.layout.ty,
153+
dest = dest.layout.ty,
158154
);
159155
}
160156

0 commit comments

Comments
 (0)