Rollup merge of #28874 - GuillaumeGomez:error_code, r=Manishearth
r? @Manishearth
This commit is contained in:
commit
4b44296308
|
@ -12,6 +12,21 @@
|
||||||
|
|
||||||
register_long_diagnostics! {
|
register_long_diagnostics! {
|
||||||
|
|
||||||
|
E0515: r##"
|
||||||
|
A constant index expression was out of bounds. Erroneous code example:
|
||||||
|
|
||||||
|
```
|
||||||
|
let x = &[0, 1, 2][7]; // error: const index-expr is out of bounds
|
||||||
|
```
|
||||||
|
|
||||||
|
Please specify a valid index (not inferior to 0 or superior to array length).
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
let x = &[0, 1, 2][2]; // ok!
|
||||||
|
```
|
||||||
|
"##,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
register_diagnostics! {
|
register_diagnostics! {
|
||||||
|
|
|
@ -628,7 +628,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
if iv >= len {
|
if iv >= len {
|
||||||
// FIXME #3170: report this earlier on in the const-eval
|
// FIXME #3170: report this earlier on in the const-eval
|
||||||
// pass. Reporting here is a bit late.
|
// pass. Reporting here is a bit late.
|
||||||
cx.sess().span_err(e.span,
|
span_err!(cx.sess(), e.span, E0515,
|
||||||
"const index-expr is out of bounds");
|
"const index-expr is out of bounds");
|
||||||
C_undef(val_ty(arr).element_type())
|
C_undef(val_ty(arr).element_type())
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue