about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-11-01 21:40:05 +0100
committerGitHub <noreply@github.com>2023-11-01 21:40:05 +0100
commit3087b63d1f305690b2146ba5f0d7295630e60ca9 (patch)
tree33520f05f49a12907c599012a36b1ae6986db373
parent2b2360abb1a2daf7b9486cb8fec85356c4574427 (diff)
parent88f06885300ae97f7fb04295cc17394df48522e4 (diff)
downloadrust-3087b63d1f305690b2146ba5f0d7295630e60ca9.tar.gz
rust-3087b63d1f305690b2146ba5f0d7295630e60ca9.zip
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.
-rw-r--r--compiler/rustc_const_eval/src/interpret/cast.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs
index 8fc0205d6c7..f4cb12c8d43 100644
--- a/compiler/rustc_const_eval/src/interpret/cast.rs
+++ b/compiler/rustc_const_eval/src/interpret/cast.rs
@@ -145,16 +145,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                 assert!(dest.layout.is_sized());
                 assert_eq!(cast_ty, dest.layout.ty); // we otherwise ignore `cast_ty` enirely...
                 if src.layout.size != dest.layout.size {
-                    let src_bytes = src.layout.size.bytes();
-                    let dest_bytes = dest.layout.size.bytes();
-                    let src_ty = format!("{}", src.layout.ty);
-                    let dest_ty = format!("{}", dest.layout.ty);
                     throw_ub_custom!(
                         fluent::const_eval_invalid_transmute,
-                        src_bytes = src_bytes,
-                        dest_bytes = dest_bytes,
-                        src = src_ty,
-                        dest = dest_ty,
+                        src_bytes = src.layout.size.bytes(),
+                        dest_bytes = dest.layout.size.bytes(),
+                        src = src.layout.ty,
+                        dest = dest.layout.ty,
                     );
                 }