diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-07-31 18:52:10 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-31 18:52:10 +1000 |
| commit | 880113eff908e5d08ea5552f7bfd3ae86c601484 (patch) | |
| tree | 21fe77b968af8f65b36ef5522230c401cae36405 /tests | |
| parent | 32e7a4b92b109c24e9822c862a7c74436b50e564 (diff) | |
| parent | 761c4e308ca17c1d6d893c7d512f579728b1552f (diff) | |
| download | rust-880113eff908e5d08ea5552f7bfd3ae86c601484.tar.gz rust-880113eff908e5d08ea5552f7bfd3ae86c601484.zip | |
Rollup merge of #144657 - Muscraft:fix-unicode-close-window, r=fee1-dead
fix: Only "close the window" when its the last annotated file
While comparing the Unicode theme output of `rustc` and `annotate-snippets`, I found that `rustc` would ["close the window"](https://github.com/rust-lang/rust/blob/686bc1c5f9c06762b18082434c04d514acf6707e/compiler/rustc_errors/src/emitter.rs#L1025-L1027) (draw a `╰╴`), even though there were other annotated files that followed the current one. This PR makes it so the emitter will only "close the window" on the last annotated file.
Before:
```
error[E0624]: method `method` is private
╭▸ $DIR/close_window.rs:9:7
│
LL │ s.method();
╰╴ ━━━━━━ private method
│
⸬ $DIR/auxiliary/close_window.rs:3:5
│
LL │ fn method(&self) {}
╰╴ ──────────────── private method defined here
```
After:
```
error[E0624]: method `method` is private
╭▸ $DIR/close_window.rs:9:7
│
LL │ s.method();
│ ━━━━━━ private method
│
⸬ $DIR/auxiliary/close_window.rs:3:5
│
LL │ fn method(&self) {}
╰╴ ──────────────── private method defined here
```
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/error-emitter/auxiliary/close_window.rs | 4 | ||||
| -rw-r--r-- | tests/ui/error-emitter/close_window.ascii.stderr | 14 | ||||
| -rw-r--r-- | tests/ui/error-emitter/close_window.rs | 11 | ||||
| -rw-r--r-- | tests/ui/error-emitter/close_window.unicode.stderr | 14 |
4 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/error-emitter/auxiliary/close_window.rs b/tests/ui/error-emitter/auxiliary/close_window.rs new file mode 100644 index 00000000000..e41313b6ab3 --- /dev/null +++ b/tests/ui/error-emitter/auxiliary/close_window.rs @@ -0,0 +1,4 @@ +pub struct S; +impl S { + fn method(&self) {} +} diff --git a/tests/ui/error-emitter/close_window.ascii.stderr b/tests/ui/error-emitter/close_window.ascii.stderr new file mode 100644 index 00000000000..e208b709393 --- /dev/null +++ b/tests/ui/error-emitter/close_window.ascii.stderr @@ -0,0 +1,14 @@ +error[E0624]: method `method` is private + --> $DIR/close_window.rs:9:7 + | +LL | s.method(); + | ^^^^^^ private method + | + ::: $DIR/auxiliary/close_window.rs:3:5 + | +LL | fn method(&self) {} + | ---------------- private method defined here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/tests/ui/error-emitter/close_window.rs b/tests/ui/error-emitter/close_window.rs new file mode 100644 index 00000000000..879507c287a --- /dev/null +++ b/tests/ui/error-emitter/close_window.rs @@ -0,0 +1,11 @@ +//@ aux-build:close_window.rs +//@ revisions: ascii unicode +//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode + +extern crate close_window; + +fn main() { + let s = close_window::S; + s.method(); + //[ascii]~^ ERROR method `method` is private +} diff --git a/tests/ui/error-emitter/close_window.unicode.stderr b/tests/ui/error-emitter/close_window.unicode.stderr new file mode 100644 index 00000000000..56ab6daa278 --- /dev/null +++ b/tests/ui/error-emitter/close_window.unicode.stderr @@ -0,0 +1,14 @@ +error[E0624]: method `method` is private + ╭▸ $DIR/close_window.rs:9:7 + │ +LL │ s.method(); + │ ━━━━━━ private method + │ + ⸬ $DIR/auxiliary/close_window.rs:3:5 + │ +LL │ fn method(&self) {} + ╰╴ ──────────────── private method defined here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0624`. |
