Skip to content

Commit 7294fcd

Browse files
japaricRalfJung
authored andcommitted
improve panic message
1 parent bd3c781 commit 7294fcd

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/librustc_codegen_llvm/mir/block.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,12 @@ impl FunctionCx<'a, 'll, 'tcx> {
475475
.max(tcx.data_layout.i32_align)
476476
.max(tcx.data_layout.pointer_align);
477477

478-
let str = if intrinsic == Some("init") {
479-
"Attempted to instantiate an uninhabited type (e.g. `!`) \
480-
using mem::zeroed()"
481-
} else {
482-
"Attempted to instantiate an uninhabited type (e.g. `!`) \
483-
using mem::uninitialized()"
484-
};
485-
let msg_str = Symbol::intern(str).as_str();
478+
let str = format!(
479+
"Attempted to instantiate uninhabited type {} using mem::{}",
480+
sig.output(),
481+
if intrinsic == Some("init") { "zeroed" } else { "uninitialized" }
482+
);
483+
let msg_str = Symbol::intern(&str).as_str();
486484
let msg_str = C_str_slice(bx.cx, msg_str);
487485
let msg_file_line_col = C_struct(bx.cx,
488486
&[msg_str, filename, line, col],

0 commit comments

Comments
 (0)