Skip to content

Commit 107a29a

Browse files
committed
Emit lints in the order in which they occur in the file.
1 parent 25e272e commit 107a29a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,11 @@ fn check_arms<'p, 'tcx>(
390390
}
391391
}
392392
Useful(unreachables) => {
393-
for set in unreachables {
394-
for span in set {
395-
unreachable_pattern(cx.tcx, span, id, None);
396-
}
393+
let mut unreachables: Vec<_> = unreachables.into_iter().flatten().collect();
394+
// Emit lints in the order in which they occur in the file.
395+
unreachables.sort_unstable();
396+
for span in unreachables {
397+
unreachable_pattern(cx.tcx, span, id, None);
397398
}
398399
}
399400
UsefulWithWitness(_) => bug!(),

src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ LL | (1 | 1,) => {}
7777
| ^
7878

7979
error: unreachable pattern
80-
--> $DIR/exhaustiveness-unreachable-pattern.rs:55:15
80+
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
8181
|
82-
LL | | 0] => {}
82+
LL | | 0
8383
| ^
8484

8585
error: unreachable pattern
86-
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
86+
--> $DIR/exhaustiveness-unreachable-pattern.rs:55:15
8787
|
88-
LL | | 0
88+
LL | | 0] => {}
8989
| ^
9090

9191
error: unreachable pattern

0 commit comments

Comments
 (0)