Skip to content

Commit 41bfd18

Browse files
committed
resolve: Sort E0408 errors by Symbol str
Previously errors were sorted by Symbol index instead of the string. The indexes are not the same between architectures because Symbols for architecture extensions (e.g. x86 AVX or RISC-V d) are interned before the source file is parsed. RISC-V's naming of extensions after single letters led to it having errors sorted differently for test cases using single letter variable names. Instead sort the errors by the Symbol string so that it is stable across architectures.
1 parent 8edb05c commit 41bfd18

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

src/librustc_resolve/late.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,8 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13231323

13241324
// 3) Report all missing variables we found.
13251325
let mut missing_vars = missing_vars.iter_mut().collect::<Vec<_>>();
1326-
missing_vars.sort();
1326+
missing_vars.sort_by_key(|(sym, _err)| sym.as_str());
1327+
13271328
for (name, mut v) in missing_vars {
13281329
if inconsistent_vars.contains_key(name) {
13291330
v.could_be_path = false;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
error[E0408]: variable `x` is not bound in all patterns
2-
--> $DIR/mismatched-bindings-async-fn.rs:6:17
3-
|
4-
LL | async fn a((x | s): String) {}
5-
| - ^ pattern doesn't bind `x`
6-
| |
7-
| variable not in all patterns
8-
91
error[E0408]: variable `s` is not bound in all patterns
102
--> $DIR/mismatched-bindings-async-fn.rs:6:13
113
|
@@ -15,12 +7,12 @@ LL | async fn a((x | s): String) {}
157
| pattern doesn't bind `s`
168

179
error[E0408]: variable `x` is not bound in all patterns
18-
--> $DIR/mismatched-bindings-async-fn.rs:11:13
10+
--> $DIR/mismatched-bindings-async-fn.rs:6:17
1911
|
20-
LL | let x | s = String::new();
21-
| - ^ pattern doesn't bind `x`
22-
| |
23-
| variable not in all patterns
12+
LL | async fn a((x | s): String) {}
13+
| - ^ pattern doesn't bind `x`
14+
| |
15+
| variable not in all patterns
2416

2517
error[E0408]: variable `s` is not bound in all patterns
2618
--> $DIR/mismatched-bindings-async-fn.rs:11:9
@@ -30,6 +22,14 @@ LL | let x | s = String::new();
3022
| |
3123
| pattern doesn't bind `s`
3224

25+
error[E0408]: variable `x` is not bound in all patterns
26+
--> $DIR/mismatched-bindings-async-fn.rs:11:13
27+
|
28+
LL | let x | s = String::new();
29+
| - ^ pattern doesn't bind `x`
30+
| |
31+
| variable not in all patterns
32+
3333
error: aborting due to 4 previous errors
3434

3535
For more information about this error, try `rustc --explain E0408`.

src/test/ui/span/issue-39698.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}
88
| | pattern doesn't bind `a`
99
| variable not in all patterns
1010

11-
error[E0408]: variable `d` is not bound in all patterns
12-
--> $DIR/issue-39698.rs:10:37
13-
|
14-
LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); }
15-
| - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d`
16-
| | | |
17-
| | | pattern doesn't bind `d`
18-
| | variable not in all patterns
19-
| variable not in all patterns
20-
2111
error[E0408]: variable `b` is not bound in all patterns
2212
--> $DIR/issue-39698.rs:10:9
2313
|
@@ -38,6 +28,16 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}
3828
| | pattern doesn't bind `c`
3929
| pattern doesn't bind `c`
4030

31+
error[E0408]: variable `d` is not bound in all patterns
32+
--> $DIR/issue-39698.rs:10:37
33+
|
34+
LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); }
35+
| - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d`
36+
| | | |
37+
| | | pattern doesn't bind `d`
38+
| | variable not in all patterns
39+
| variable not in all patterns
40+
4141
error: aborting due to 4 previous errors
4242

4343
For more information about this error, try `rustc --explain E0408`.

0 commit comments

Comments
 (0)