about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-07-29 20:19:53 +1000
committerGitHub <noreply@github.com>2025-07-29 20:19:53 +1000
commit15ddf9c7b3d2bd8b00de08cfebcf47c00081db03 (patch)
tree79dd252949182c7174977dd1f40cf1258eadd848 /tests
parent03bb80c25453a58cec0b918c57402fe6e6372ea6 (diff)
parentaa9767290e46c9c73fa1fd3abb52277b4d07cfae (diff)
downloadrust-15ddf9c7b3d2bd8b00de08cfebcf47c00081db03.tar.gz
rust-15ddf9c7b3d2bd8b00de08cfebcf47c00081db03.zip
Rollup merge of #144609 - Muscraft:right-align, r=compiler-errors
feat: Right align line numbers

As part of my work on getting `annotate-snipptes` to be used as `rustc`'s renderer, I realized that `rustc` left-aligned line numbers, while `annotate-snippets` right-aligned them. This PR switches `rustc` to right-align the line numbers, matching `annotate-snippets`. In practice, this change isn't very noticeable in day-to-day output, as it only shows up when a diagnostic span contains line numbers with different lengths (9->10, 99->100, 999->1000, etc.).

`rustc`
```
error[E0412]: cannot find type `F` in this scope
  --> $DIR/ui-testing-optout.rs:92:10
   |
4  | type A = B;
   | ----------- similarly named type alias `A` defined here
...
92 | type E = F;
   |          ^ help: a type alias with a similar name exists: `A`
```
`annotate-snippets`
```
error[E0412]: cannot find type `F` in this scope
  --> $DIR/ui-testing-optout.rs:92:10
   |
 4 | type A = B;
   | ----------- similarly named type alias `A` defined here
...
92 | type E = F;
   |          ^ help: a type alias with a similar name exists: `A`
```

r? ``@compiler-errors``
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr12
-rw-r--r--tests/rustdoc-ui/doctest/standalone-warning-2024.stderr2
-rw-r--r--tests/ui/compiletest-self-test/ui-testing-optout.stderr2
-rw-r--r--tests/ui/modules/issue-107649.stderr4
4 files changed, 10 insertions, 10 deletions
diff --git a/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr b/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr
index 7f131153540..9433a0ba00e 100644
--- a/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr
+++ b/tests/run-make/crate-loading-crate-depends-on-itself/foo.stderr
@@ -7,19 +7,19 @@ error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied
 note: there are multiple different versions of crate `foo` in the dependency graph
   --> foo-current.rs:7:1
    |
-4  | extern crate foo;
+ 4 | extern crate foo;
    | ----------------- one version of crate `foo` used here, as a direct dependency of the current crate
-5  |
-6  | pub struct Struct;
+ 5 |
+ 6 | pub struct Struct;
    | ----------------- this type implements the required trait
-7  | pub trait Trait {}
+ 7 | pub trait Trait {}
    | ^^^^^^^^^^^^^^^ this is the required trait
    |
   ::: foo-prev.rs:X:Y
    |
-4  | pub struct Struct;
+ 4 | pub struct Struct;
    | ----------------- this type doesn't implement the required trait
-5  | pub trait Trait {}
+ 5 | pub trait Trait {}
    | --------------- this is the found trait
    = note: two types coming from two different versions of the same crate are different types even if they look the same
    = help: you can use `cargo tree` to explore your dependency tree
diff --git a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr
index bfc1e919404..ce65557c2c4 100644
--- a/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr
+++ b/tests/rustdoc-ui/doctest/standalone-warning-2024.stderr
@@ -15,7 +15,7 @@ error: unknown attribute `standalone`
 note: the lint level is defined here
   --> $DIR/standalone-warning-2024.rs:9:9
    |
-9  | #![deny(warnings)]
+ 9 | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]`
 
diff --git a/tests/ui/compiletest-self-test/ui-testing-optout.stderr b/tests/ui/compiletest-self-test/ui-testing-optout.stderr
index 652c472c0bc..f1d03eab14a 100644
--- a/tests/ui/compiletest-self-test/ui-testing-optout.stderr
+++ b/tests/ui/compiletest-self-test/ui-testing-optout.stderr
@@ -16,7 +16,7 @@ error[E0412]: cannot find type `D` in this scope
 error[E0412]: cannot find type `F` in this scope
   --> $DIR/ui-testing-optout.rs:92:10
    |
-4  | type A = B;
+ 4 | type A = B;
    | ----------- similarly named type alias `A` defined here
 ...
 92 | type E = F;
diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr
index 802ac669a10..49d7cb4e0aa 100644
--- a/tests/ui/modules/issue-107649.stderr
+++ b/tests/ui/modules/issue-107649.stderr
@@ -9,8 +9,8 @@ error[E0277]: `Dummy` doesn't implement `Debug`
 help: consider annotating `Dummy` with `#[derive(Debug)]`
    --> $DIR/auxiliary/dummy_lib.rs:2:1
     |
-2   + #[derive(Debug)]
-3   | pub struct Dummy;
+  2 + #[derive(Debug)]
+  3 | pub struct Dummy;
     |
 
 error: aborting due to 1 previous error