Skip to content

Conversation

Muscraft
Copy link
Member

annotate-snippets does not have a "UI test" mode like rustc, where the code offset is not subtracted from the column width. 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

@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. labels Sep 29, 2025
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@RalfJung
Copy link
Member

RalfJung commented Sep 29, 2025

From a test suite maintenance perspective this looks not great -- how does one know whether one has to add a random --diagnostic-width=145 to a Miri test? What happens if I don't add that?

@Muscraft
Copy link
Member Author

Personally, I would only add --diagnostic-width to tests that explicitly test how width affects the output. I only added --diagnostic-width to the tests in this PR to keep them the same as before. Without --diagnostic-width the miri tests would look:

error: Undefined Behavior: `simd_cast` intrinsic called on 3.40282347E+38f32 which cannot be represented in target type `i32`
  --> tests/fail/intrinsics/simd-float-to-int.rs:LL:CC
   |
LL | ...   let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked();
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
   |
   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
   = note: BACKTRACE:
   = note: inside `main` at tests/fail/intrinsics/simd-float-to-int.rs:LL:CC
error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required
  --> tests/fail/intrinsics/copy_unaligned.rs:LL:CC
   |
LL | ...   std::intrinsics::copy_nonoverlapping(&data[5], ptr, 0);
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
   |
   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
   = note: BACKTRACE:
   = note: inside `main` at tests/fail/intrinsics/copy_unaligned.rs:LL:CC

Branch with miri output changes

@RalfJung
Copy link
Member

Without commenting on whether we want to have those output changes or not -- if the output does change like that, I'd much rather just have the stderr files updated in Miri than add random compiler flags.

@@ -1,4 +1,5 @@
//@aux-build:proc_macros.rs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting this out into a separate commit!

@nnethercote
Copy link
Contributor

I'm going to pass this on to David, who already had intelligent things to say in the Zulip thread.

r? davidtwco

@rustbot rustbot assigned davidtwco and unassigned nnethercote Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants