From 41bfd18e0266b990708879c2bc22edb2626b1532 Mon Sep 17 00:00:00 2001 From: Tom Eccles Date: Tue, 2 Jun 2020 12:07:43 +0100 Subject: [PATCH] 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. --- src/librustc_resolve/late.rs | 3 ++- .../mismatched-bindings-async-fn.stderr | 26 +++++++++---------- src/test/ui/span/issue-39698.stderr | 20 +++++++------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 3b49b3b6ff7..2e37f666b39 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -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::>(); - 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; diff --git a/src/test/ui/or-patterns/mismatched-bindings-async-fn.stderr b/src/test/ui/or-patterns/mismatched-bindings-async-fn.stderr index b9c74266411..998577cf4b5 100644 --- a/src/test/ui/or-patterns/mismatched-bindings-async-fn.stderr +++ b/src/test/ui/or-patterns/mismatched-bindings-async-fn.stderr @@ -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 | @@ -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 @@ -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`. diff --git a/src/test/ui/span/issue-39698.stderr b/src/test/ui/span/issue-39698.stderr index 7fa5d24c41b..445df90d395 100644 --- a/src/test/ui/span/issue-39698.stderr +++ b/src/test/ui/span/issue-39698.stderr @@ -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 | @@ -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`.