Skip to content

Commit ec4ba27

Browse files
Add span_help for E0002
1 parent 94ddfc7 commit ec4ba27

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ E0002: r##"
4444
This error indicates that an empty match expression is invalid because the type
4545
it is matching on is non-empty (there exist values of this type). In safe code
4646
it is impossible to create an instance of an empty type, so empty match
47-
expressions are almost never desired. This error is typically fixed by adding
47+
expressions are almost never desired. This error is typically fixed by adding
4848
one or more cases to the match expression.
4949
5050
An example of an empty type is `enum Empty { }`. So, the following will work:

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
218218
span_err!(cx.tcx.sess, ex.span, E0002,
219219
"non-exhaustive patterns: type {} is non-empty",
220220
pat_ty);
221+
span_help!(cx.tcx.sess, ex.span,
222+
"Please ensure that all possible cases are being handled; \
223+
possibly adding wildcards or more match arms.");
221224
}
222225
// If the type *is* empty, it's vacuously exhaustive
223226
return;

0 commit comments

Comments
 (0)