Skip to content

Commit

Permalink
resolve: Sort E0408 errors by Symbol str
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tblah committed Jun 4, 2020
1 parent 8edb05c commit 41bfd18
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,8 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {

// 3) Report all missing variables we found.
let mut missing_vars = missing_vars.iter_mut().collect::<Vec<_>>();
missing_vars.sort();
missing_vars.sort_by_key(|(sym, _err)| sym.as_str());

for (name, mut v) in missing_vars {
if inconsistent_vars.contains_key(name) {
v.could_be_path = false;
Expand Down
26 changes: 13 additions & 13 deletions src/test/ui/or-patterns/mismatched-bindings-async-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
error[E0408]: variable `x` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:6:17
|
LL | async fn a((x | s): String) {}
| - ^ pattern doesn't bind `x`
| |
| variable not in all patterns

error[E0408]: variable `s` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:6:13
|
Expand All @@ -15,12 +7,12 @@ LL | async fn a((x | s): String) {}
| pattern doesn't bind `s`

error[E0408]: variable `x` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:11:13
--> $DIR/mismatched-bindings-async-fn.rs:6:17
|
LL | let x | s = String::new();
| - ^ pattern doesn't bind `x`
| |
| variable not in all patterns
LL | async fn a((x | s): String) {}
| - ^ pattern doesn't bind `x`
| |
| variable not in all patterns

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

error[E0408]: variable `x` is not bound in all patterns
--> $DIR/mismatched-bindings-async-fn.rs:11:13
|
LL | let x | s = String::new();
| - ^ pattern doesn't bind `x`
| |
| variable not in all patterns

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0408`.
20 changes: 10 additions & 10 deletions src/test/ui/span/issue-39698.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}
| | pattern doesn't bind `a`
| variable not in all patterns

error[E0408]: variable `d` is not bound in all patterns
--> $DIR/issue-39698.rs:10:37
|
LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); }
| - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d`
| | | |
| | | pattern doesn't bind `d`
| | variable not in all patterns
| variable not in all patterns

error[E0408]: variable `b` is not bound in all patterns
--> $DIR/issue-39698.rs:10:9
|
Expand All @@ -38,6 +28,16 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}
| | pattern doesn't bind `c`
| pattern doesn't bind `c`

error[E0408]: variable `d` is not bound in all patterns
--> $DIR/issue-39698.rs:10:37
|
LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); }
| - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d`
| | | |
| | | pattern doesn't bind `d`
| | variable not in all patterns
| variable not in all patterns

error: aborting due to 4 previous errors

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

0 comments on commit 41bfd18

Please sign in to comment.