Skip to content

Commit 6ed1c59

Browse files
committed
Rollup merge of rust-lang#28231 - GuillaumeGomez:help_note, r=Manishearth
r? @Manishearth
2 parents 3610c73 + 771ab35 commit 6ed1c59

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/librustc/diagnostics.rs

+16-4
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:
@@ -218,7 +218,14 @@ match x {
218218
E0010: r##"
219219
The value of statics and constants must be known at compile time, and they live
220220
for the entire lifetime of a program. Creating a boxed value allocates memory on
221-
the heap at runtime, and therefore cannot be done at compile time.
221+
the heap at runtime, and therefore cannot be done at compile time. Erroneous
222+
code example:
223+
224+
```
225+
#![feature(box_syntax)]
226+
227+
const CON : Box<i32> = box 0;
228+
```
222229
"##,
223230

224231
E0011: r##"
@@ -335,7 +342,6 @@ is not allowed.
335342
336343
If you really want global mutable state, try using `static mut` or a global
337344
`UnsafeCell`.
338-
339345
"##,
340346

341347
E0018: r##"
@@ -399,7 +405,13 @@ fn main() {
399405

400406
E0020: r##"
401407
This error indicates that an attempt was made to divide by zero (or take the
402-
remainder of a zero divisor) in a static or constant expression.
408+
remainder of a zero divisor) in a static or constant expression. Erroneous
409+
code example:
410+
411+
```
412+
const X: i32 = 42 / 0;
413+
// error: attempted to divide by zero in a constant expression
414+
```
403415
"##,
404416

405417
E0022: r##"

src/librustc/middle/check_match.rs

+3
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)