about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-03-31 17:46:26 +0200
committerRalf Jung <post@ralfj.de>2020-03-31 17:58:14 +0200
commit96deb950ac5771801c66b329707c748f65d41b34 (patch)
treeee48307971033ed8513b0dd6e0884d4978f3991d
parentad74480cb209eec4d09b12d5810c221d6b2f2d4c (diff)
downloadrust-96deb950ac5771801c66b329707c748f65d41b34.tar.gz
rust-96deb950ac5771801c66b329707c748f65d41b34.zip
const backtrace: do not skip first frame
-rw-r--r--src/librustc_middle/mir/interpret/error.rs9
-rw-r--r--src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr1
-rw-r--r--src/test/ui/consts/miri_unleashed/abi-mismatch.stderr1
-rw-r--r--src/test/ui/consts/miri_unleashed/drop.stderr5
-rw-r--r--src/test/ui/consts/offset_from_ub.stderr5
-rw-r--r--src/test/ui/consts/uninhabited-const-issue-61744.stderr1
6 files changed, 17 insertions, 5 deletions
diff --git a/src/librustc_middle/mir/interpret/error.rs b/src/librustc_middle/mir/interpret/error.rs
index 5a4588d746d..d46f1bc4cc4 100644
--- a/src/librustc_middle/mir/interpret/error.rs
+++ b/src/librustc_middle/mir/interpret/error.rs
@@ -167,10 +167,11 @@ impl<'tcx> ConstEvalErr<'tcx> {
             if let Some(span_msg) = span_msg {
                 err.span_label(self.span, span_msg);
             }
-            // Add spans for the stacktrace.
-            // Skip the first, which is the place of the error.
-            for frame_info in self.stacktrace.iter().skip(1) {
-                err.span_label(frame_info.span, frame_info.to_string());
+            // Add spans for the stacktrace. Don't print a single-line backtrace though.
+            if self.stacktrace.len() > 1 {
+                for frame_info in &self.stacktrace {
+                    err.span_label(frame_info.span, frame_info.to_string());
+                }
             }
             // Let the caller finish the job.
             emit(err)
diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr
index fa5534c9879..f1e91920f17 100644
--- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr
+++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr
@@ -5,6 +5,7 @@ LL |     unsafe { std::mem::transmute(()) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^
    |              |
    |              transmuting to uninhabited type
+   |              inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
    |              inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26
 ...
 LL | const FOO: [Empty; 3] = [foo(); 3];
diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr
index a8906bd00b7..8ed1431dd31 100644
--- a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr
+++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr
@@ -17,6 +17,7 @@ LL |     my_fn();
    |     ^^^^^^^
    |     |
    |     calling a function with ABI C using caller ABI Rust
+   |     inside `call_rust_fn` at $DIR/abi-mismatch.rs:9:5
    |     inside `VAL` at $DIR/abi-mismatch.rs:13:17
 ...
 LL | const VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
diff --git a/src/test/ui/consts/miri_unleashed/drop.stderr b/src/test/ui/consts/miri_unleashed/drop.stderr
index 3a1efb5ab0c..5d560fab835 100644
--- a/src/test/ui/consts/miri_unleashed/drop.stderr
+++ b/src/test/ui/consts/miri_unleashed/drop.stderr
@@ -12,7 +12,10 @@ LL | |     // Code here does not matter - this is replaced by the
 LL | |     // real drop glue by the compiler.
 LL | |     drop_in_place(to_drop)
 LL | | }
-   | |_^ calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop`
+   | | ^
+   | | |
+   | |_calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop`
+   |   inside `std::intrinsics::drop_in_place::<std::vec::Vec<i32>> - shim(Some(std::vec::Vec<i32>))` at $SRC_DIR/libcore/ptr/mod.rs:LL:COL
    | 
   ::: $DIR/drop.rs:23:1
    |
diff --git a/src/test/ui/consts/offset_from_ub.stderr b/src/test/ui/consts/offset_from_ub.stderr
index 64e898aa38f..f1a183b229d 100644
--- a/src/test/ui/consts/offset_from_ub.stderr
+++ b/src/test/ui/consts/offset_from_ub.stderr
@@ -5,6 +5,7 @@ LL |           intrinsics::ptr_offset_from(self, origin)
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |           |
    |           ptr_offset_from cannot compute offset of pointers into different allocations.
+   |           inside `std::ptr::const_ptr::<impl *const Struct>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
    |           inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:22:27
    | 
   ::: $DIR/offset_from_ub.rs:16:1
@@ -27,6 +28,7 @@ LL |           intrinsics::ptr_offset_from(self, origin)
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |           |
    |           unable to turn bytes into a pointer
+   |           inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
    |           inside `NOT_PTR` at $DIR/offset_from_ub.rs:28:14
    | 
   ::: $DIR/offset_from_ub.rs:26:1
@@ -44,6 +46,7 @@ LL |           intrinsics::ptr_offset_from(self, origin)
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |           |
    |           exact_div: 1isize cannot be divided by 2isize without remainder
+   |           inside `std::ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
    |           inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:36:14
    | 
   ::: $DIR/offset_from_ub.rs:31:1
@@ -64,6 +67,7 @@ LL |           intrinsics::ptr_offset_from(self, origin)
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |           |
    |           invalid use of NULL pointer
+   |           inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
    |           inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:42:14
    | 
   ::: $DIR/offset_from_ub.rs:39:1
@@ -82,6 +86,7 @@ LL |           intrinsics::ptr_offset_from(self, origin)
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |           |
    |           unable to turn bytes into a pointer
+   |           inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
    |           inside `DIFFERENT_INT` at $DIR/offset_from_ub.rs:49:14
    | 
   ::: $DIR/offset_from_ub.rs:45:1
diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.stderr b/src/test/ui/consts/uninhabited-const-issue-61744.stderr
index 024f9782d4a..ca232380897 100644
--- a/src/test/ui/consts/uninhabited-const-issue-61744.stderr
+++ b/src/test/ui/consts/uninhabited-const-issue-61744.stderr
@@ -67,6 +67,7 @@ LL |     hint_unreachable()
    |     inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
    |     inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
    |     inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
+   |     inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
    |     inside `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:4:5
 ...
 LL |     fake_type()