Skip to content

Commit 447d57f

Browse files
author
mejrs
committed
Add more normalization and tests
1 parent 854b316 commit 447d57f

13 files changed

+101
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// compile-flags: -Z track-diagnostics
22
// error-pattern: created at
33

4+
// Normalize the emitted location so this doesn't need
5+
// updating everytime someone adds or removes a line.
6+
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL"
7+
48
struct A;
59
struct B;
610
const S: A = B;

src/test/rustdoc-ui/track-diagnostics.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
error[E0308]: mismatched types
2-
--> $DIR/track-diagnostics.rs:6:14
2+
--> $DIR/track-diagnostics.rs:$LINE::$COL
33
|
44
LL | const S: A = B;
55
| ^ expected struct `A`, found struct `B`
6-
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31
6+
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL
77

88
error: aborting due to previous error
99

src/test/rustdoc-ui/z-help.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
-Z time-passes=val -- measure time of each rustc pass (default: no)
171171
-Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details)
172172
-Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no)
173-
-Z track-diagnostics=val -- Tracks where in rustc a diagnostic was emitted
173+
-Z track-diagnostics=val -- tracks where in rustc a diagnostic was emitted
174174
-Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation)
175175
-Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics
176176
-Z translate-lang=val -- language identifier for diagnostic output
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// compile-flags: -Z track-diagnostics
22
// error-pattern: created at
33

4+
// Normalize the emitted location so this doesn't need
5+
// updating everytime someone adds or removes a line.
6+
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL"
7+
// normalize-stderr-test "note: rustc .+ running on .+" -> "note: rustc $$VERSION running on $$TARGET"
8+
49
fn main() {
510
break rust
611
}

src/test/ui/track-diagnostics/track.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
error[E0425]: cannot find value `rust` in this scope
2-
--> $DIR/track.rs:5:11
2+
--> $DIR/track.rs:$LINE::$COL
33
|
44
LL | break rust
55
| ^^^^ not found in this scope
6-
-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:289:28
6+
-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL
77

88
error[E0268]: `break` outside of a loop
9-
--> $DIR/track.rs:5:5
9+
--> $DIR/track.rs:$LINE::$COL
1010
|
1111
LL | break rust
1212
| ^^^^^^^^^^ cannot `break` outside of a loop
13-
-Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:957:10
13+
-Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:$LINE::$COL
1414

1515
error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?
1616

1717
note: the compiler expectedly panicked. this is a feature.
1818

1919
note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675
2020

21-
note: rustc 1.66.0-dev running on x86_64-pc-windows-msvc
21+
note: rustc $VERSION running on $TARGET
2222

2323
error: aborting due to 3 previous errors
2424

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: -Z track-diagnostics
2+
// error-pattern: created at
3+
4+
// Normalize the emitted location so this doesn't need
5+
// updating everytime someone adds or removes a line.
6+
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL"
7+
8+
fn main() {
9+
let _moved @ _from = String::from("foo");
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0382]: use of moved value
2+
--> $DIR/track2.rs:$LINE::$COL
3+
|
4+
LL | let _moved @ _from = String::from("foo");
5+
| ^^^^^^ ----- ------------------- move occurs because value has type `String`, which does not implement the `Copy` trait
6+
| | |
7+
| | value moved here
8+
| value used here after move
9+
-Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:$LINE::$COL
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0382`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: -Z track-diagnostics
2+
// error-pattern: created at
3+
4+
// Normalize the emitted location so this doesn't need
5+
// updating everytime someone adds or removes a line.
6+
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL"
7+
8+
fn main() {
9+
let _unimported = Blah { field: u8 };
10+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0422]: cannot find struct, variant or union type `Blah` in this scope
2+
--> $DIR/track3.rs:$LINE::$COL
3+
|
4+
LL | let _unimported = Blah { field: u8 };
5+
| ^^^^ not found in this scope
6+
-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL
7+
8+
error[E0423]: expected value, found builtin type `u8`
9+
--> $DIR/track3.rs:$LINE::$COL
10+
|
11+
LL | let _unimported = Blah { field: u8 };
12+
| ^^ not a value
13+
-Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:$LINE::$COL
14+
15+
error: aborting due to 2 previous errors
16+
17+
Some errors have detailed explanations: E0422, E0423.
18+
For more information about an error, try `rustc --explain E0422`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile-flags: -Z track-diagnostics
2+
// error-pattern: created at
3+
4+
// Normalize the emitted location so this doesn't need
5+
// updating everytime someone adds or removes a line.
6+
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL"
7+
8+
pub onion {
9+
Owo(u8),
10+
Uwu(i8),
11+
}
12+
13+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: missing `struct` for struct definition
2+
--> $DIR/track4.rs:$LINE::$COL
3+
|
4+
LL | pub onion {
5+
| ^
6+
-Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/diagnostics.rs:$LINE::$COL
7+
|
8+
help: add `struct` here to parse `onion` as a public struct
9+
|
10+
LL | pub struct onion {
11+
| ++++++
12+
13+
error: aborting due to previous error
14+

src/tools/clippy/tests/ui/track-diagnostics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// compile-flags: -Z track-diagnostics
22
// error-pattern: created at
33

4+
// Normalize the emitted location so this doesn't need
5+
// updating everytime someone adds or removes a line.
6+
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL"
7+
48
struct A;
59
struct B;
610
const S: A = B;

src/tools/clippy/tests/ui/track-diagnostics.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
error[E0308]: mismatched types
2-
--> $DIR/track-diagnostics.rs:6:14
2+
--> $DIR/track-diagnostics.rs:$LINE::$COL
33
|
44
LL | const S: A = B;
55
| ^ expected struct `A`, found struct `B`
6-
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31
6+
-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL
77

88
error: aborting due to previous error
99

0 commit comments

Comments
 (0)