Skip to content

Commit

Permalink
Emit lints in the order in which they occur in the file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Nov 5, 2020
1 parent 25e272e commit 107a29a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,11 @@ fn check_arms<'p, 'tcx>(
}
}
Useful(unreachables) => {
for set in unreachables {
for span in set {
unreachable_pattern(cx.tcx, span, id, None);
}
let mut unreachables: Vec<_> = unreachables.into_iter().flatten().collect();
// Emit lints in the order in which they occur in the file.
unreachables.sort_unstable();
for span in unreachables {
unreachable_pattern(cx.tcx, span, id, None);
}
}
UsefulWithWitness(_) => bug!(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ LL | (1 | 1,) => {}
| ^

error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:55:15
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
|
LL | | 0] => {}
LL | | 0
| ^

error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
--> $DIR/exhaustiveness-unreachable-pattern.rs:55:15
|
LL | | 0
LL | | 0] => {}
| ^

error: unreachable pattern
Expand Down

0 comments on commit 107a29a

Please sign in to comment.