]> git.lizzy.rs Git - rust.git/commitdiff
improve panic message
authorJorge Aparicio <jorge@japaric.io>
Thu, 23 Aug 2018 14:36:51 +0000 (16:36 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 30 Sep 2018 15:27:06 +0000 (17:27 +0200)
src/librustc_codegen_llvm/mir/block.rs

index 72fb9df6f81bdaca8821b89d5c452a08088aa05c..c8515a4b6fffa7d2a885f74e7c6f51ce855fff1b 100644 (file)
@@ -475,14 +475,12 @@ fn codegen_terminator(&mut self,
                         .max(tcx.data_layout.i32_align)
                         .max(tcx.data_layout.pointer_align);
 
-                    let str = if intrinsic == Some("init") {
-                        "Attempted to instantiate an uninhabited type (e.g. `!`) \
-                         using mem::zeroed()"
-                    } else {
-                        "Attempted to instantiate an uninhabited type (e.g. `!`) \
-                         using mem::uninitialized()"
-                    };
-                    let msg_str = Symbol::intern(str).as_str();
+                    let str = format!(
+                        "Attempted to instantiate uninhabited type {} using mem::{}",
+                        sig.output(),
+                        if intrinsic == Some("init") { "zeroed" } else { "uninitialized" }
+                    );
+                    let msg_str = Symbol::intern(&str).as_str();
                     let msg_str = C_str_slice(bx.cx, msg_str);
                     let msg_file_line_col = C_struct(bx.cx,
                                                     &[msg_str, filename, line, col],