Skip to content

Commit 96deb95

Browse files
committed
const backtrace: do not skip first frame
1 parent ad74480 commit 96deb95

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

src/librustc_middle/mir/interpret/error.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ impl<'tcx> ConstEvalErr<'tcx> {
167167
if let Some(span_msg) = span_msg {
168168
err.span_label(self.span, span_msg);
169169
}
170-
// Add spans for the stacktrace.
171-
// Skip the first, which is the place of the error.
172-
for frame_info in self.stacktrace.iter().skip(1) {
173-
err.span_label(frame_info.span, frame_info.to_string());
170+
// Add spans for the stacktrace. Don't print a single-line backtrace though.
171+
if self.stacktrace.len() > 1 {
172+
for frame_info in &self.stacktrace {
173+
err.span_label(frame_info.span, frame_info.to_string());
174+
}
174175
}
175176
// Let the caller finish the job.
176177
emit(err)

src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | unsafe { std::mem::transmute(()) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| transmuting to uninhabited type
8+
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
89
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26
910
...
1011
LL | const FOO: [Empty; 3] = [foo(); 3];

src/test/ui/consts/miri_unleashed/abi-mismatch.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ LL | my_fn();
1717
| ^^^^^^^
1818
| |
1919
| calling a function with ABI C using caller ABI Rust
20+
| inside `call_rust_fn` at $DIR/abi-mismatch.rs:9:5
2021
| inside `VAL` at $DIR/abi-mismatch.rs:13:17
2122
...
2223
LL | const VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });

src/test/ui/consts/miri_unleashed/drop.stderr

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ LL | | // Code here does not matter - this is replaced by the
1212
LL | | // real drop glue by the compiler.
1313
LL | | drop_in_place(to_drop)
1414
LL | | }
15-
| |_^ calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop`
15+
| | ^
16+
| | |
17+
| |_calling non-const function `<std::vec::Vec<i32> as std::ops::Drop>::drop`
18+
| 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
1619
|
1720
::: $DIR/drop.rs:23:1
1821
|

src/test/ui/consts/offset_from_ub.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ LL | intrinsics::ptr_offset_from(self, origin)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| ptr_offset_from cannot compute offset of pointers into different allocations.
8+
| inside `std::ptr::const_ptr::<impl *const Struct>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
89
| inside `DIFFERENT_ALLOC` at $DIR/offset_from_ub.rs:22:27
910
|
1011
::: $DIR/offset_from_ub.rs:16:1
@@ -27,6 +28,7 @@ LL | intrinsics::ptr_offset_from(self, origin)
2728
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2829
| |
2930
| unable to turn bytes into a pointer
31+
| inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
3032
| inside `NOT_PTR` at $DIR/offset_from_ub.rs:28:14
3133
|
3234
::: $DIR/offset_from_ub.rs:26:1
@@ -44,6 +46,7 @@ LL | intrinsics::ptr_offset_from(self, origin)
4446
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4547
| |
4648
| exact_div: 1isize cannot be divided by 2isize without remainder
49+
| inside `std::ptr::const_ptr::<impl *const u16>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
4750
| inside `NOT_MULTIPLE_OF_SIZE` at $DIR/offset_from_ub.rs:36:14
4851
|
4952
::: $DIR/offset_from_ub.rs:31:1
@@ -64,6 +67,7 @@ LL | intrinsics::ptr_offset_from(self, origin)
6467
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6568
| |
6669
| invalid use of NULL pointer
70+
| inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
6771
| inside `OFFSET_FROM_NULL` at $DIR/offset_from_ub.rs:42:14
6872
|
6973
::: $DIR/offset_from_ub.rs:39:1
@@ -82,6 +86,7 @@ LL | intrinsics::ptr_offset_from(self, origin)
8286
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8387
| |
8488
| unable to turn bytes into a pointer
89+
| inside `std::ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/libcore/ptr/const_ptr.rs:LL:COL
8590
| inside `DIFFERENT_INT` at $DIR/offset_from_ub.rs:49:14
8691
|
8792
::: $DIR/offset_from_ub.rs:45:1

src/test/ui/consts/uninhabited-const-issue-61744.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ LL | hint_unreachable()
6767
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
6868
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
6969
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
70+
| inside `fake_type::<!>` at $DIR/uninhabited-const-issue-61744.rs:4:5
7071
| inside `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:4:5
7172
...
7273
LL | fake_type()

0 commit comments

Comments
 (0)