Skip to content

Commit 82b1606

Browse files
authored
Rollup merge of #147165 - Muscraft:subtract-code-offset, r=davidtwco
test: Subtract code_offset from width for ui_testing `annotate-snippets` does not have a "UI test" mode like `rustc`, [where the code offset is not subtracted from the column width](https://github.com/rust-lang/rust/blob/f34ba774c78ea32b7c40598b8ad23e75cdac42a6/compiler/rustc_errors/src/emitter.rs#L1985-L1987). This makes it so `annotate-snippets` will shift the output for some very long tests 5 - 7 columns to the left. As part of my work to have `rustc` use `annotate-snippets`, and to reduce the test differences between the two, I figured it would be best if `rustc` started subtracting the code offset from the width as well. The first commit exists to keep the test output changes of adding a new line to a test separate from adding the `--diagnostic-width` flag in the second commit. This makes it easier to verify that adding the flag does not affect the test's output. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/annotate-snippets.20hurdles)
2 parents 9153482 + 96c2e4a commit 82b1606

9 files changed

+28
-28
lines changed

tests/fail-dep/concurrency/libc_pthread_join_joined.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: trying to join an already joined thread
22
--> tests/fail-dep/concurrency/libc_pthread_join_joined.rs:LL:CC
33
|
4-
LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
4+
LL | ... assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail-dep/concurrency/libc_pthread_join_main.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: trying to join a detached thread
22
--> tests/fail-dep/concurrency/libc_pthread_join_main.rs:LL:CC
33
|
4-
LL | assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
4+
LL | ... assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/data_race/dealloc_read_race1.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC
22
--> tests/fail/data_race/dealloc_read_race1.rs:LL:CC
33
|
4-
LL | / __rust_dealloc(
5-
LL | |
6-
LL | | ptr.0 as *mut _,
7-
LL | | std::mem::size_of::<usize>(),
8-
LL | | std::mem::align_of::<usize>(),
9-
LL | | );
10-
| |_____________^ (2) just happened here
4+
LL | / ... __rust_dealloc(
5+
LL | | ...
6+
LL | | ... ptr.0 as *mut _,
7+
LL | | ... std::mem::size_of::<usize>(),
8+
LL | | ... std::mem::align_of::<usize>(),
9+
LL | | ... );
10+
| |_______^ (2) just happened here
1111
|
1212
help: and (1) occurred earlier here
1313
--> tests/fail/data_race/dealloc_read_race1.rs:LL:CC

tests/fail/data_race/dealloc_read_race_stack.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC
22
--> tests/fail/data_race/dealloc_read_race_stack.rs:LL:CC
33
|
4-
LL | }
5-
| ^ (2) just happened here
4+
LL | ... }
5+
| ^ (2) just happened here
66
|
77
help: and (1) occurred earlier here
88
--> tests/fail/data_race/dealloc_read_race_stack.rs:LL:CC

tests/fail/data_race/dealloc_write_race1.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC
22
--> tests/fail/data_race/dealloc_write_race1.rs:LL:CC
33
|
4-
LL | / __rust_dealloc(
5-
LL | |
6-
LL | | ptr.0 as *mut _,
7-
LL | | std::mem::size_of::<usize>(),
8-
LL | | std::mem::align_of::<usize>(),
9-
LL | | );
10-
| |_____________^ (2) just happened here
4+
LL | / ... __rust_dealloc(
5+
LL | | ...
6+
LL | | ... ptr.0 as *mut _,
7+
LL | | ... std::mem::size_of::<usize>(),
8+
LL | | ... std::mem::align_of::<usize>(),
9+
LL | | ... );
10+
| |_______^ (2) just happened here
1111
|
1212
help: and (1) occurred earlier here
1313
--> tests/fail/data_race/dealloc_write_race1.rs:LL:CC

tests/fail/data_race/dealloc_write_race_stack.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC
22
--> tests/fail/data_race/dealloc_write_race_stack.rs:LL:CC
33
|
4-
LL | }
5-
| ^ (2) just happened here
4+
LL | ... }
5+
| ^ (2) just happened here
66
|
77
help: and (1) occurred earlier here
88
--> tests/fail/data_race/dealloc_write_race_stack.rs:LL:CC

tests/fail/intrinsics/copy_unaligned.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required
22
--> tests/fail/intrinsics/copy_unaligned.rs:LL:CC
33
|
4-
LL | std::intrinsics::copy_nonoverlapping(&data[5], ptr, 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
4+
LL | ... std::intrinsics::copy_nonoverlapping(&data[5], ptr, 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/simd-float-to-int.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `simd_cast` intrinsic called on 3.40282347E+38f32 which cannot be represented in target type `i32`
22
--> tests/fail/intrinsics/simd-float-to-int.rs:LL:CC
33
|
4-
LL | let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
4+
LL | ... let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/stacked_borrows/retag_data_race_read.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: Data race detected between (1) retag read on thread `unnamed-ID` and (2) non-atomic write on thread `unnamed-ID` at ALLOC
22
--> tests/fail/stacked_borrows/retag_data_race_read.rs:LL:CC
33
|
4-
LL | *p = 5;
5-
| ^^^^^^ (2) just happened here
4+
LL | ... *p = 5;
5+
| ^^^^^^ (2) just happened here
66
|
77
help: and (1) occurred earlier here
88
--> tests/fail/stacked_borrows/retag_data_race_read.rs:LL:CC

0 commit comments

Comments
 (0)