};
let param_env = ty::ParamEnv::reveal_all();
- match tcx.const_eval(param_env.and(cid)) {
- Ok(val) => collect_const(tcx, val, instance.substs, &mut neighbors),
- Err(err) => {
- let span = tcx.def_span(def_id);
- err.report_as_error(
- tcx.at(span),
- "could not evaluate static initializer",
- );
- }
+ if let Ok(val) = tcx.const_eval(param_env.and(cid)) {
+ collect_const(tcx, val, instance.substs, &mut neighbors);
}
}
MonoItem::Fn(instance) => {
static CRASH: () = symbol;
//~^ ERROR could not evaluate static initializer
//~| tried to read from foreign (extern) static
-//~^^^ ERROR could not evaluate static initializer
-//~| tried to read from foreign (extern) static
fn main() {}
pub static BAZ: u32 = *&error_message_count;
//~^ ERROR could not evaluate static initializer
//~| tried to read from foreign (extern) static
-//~^^^ ERROR could not evaluate static initializer
-//~| tried to read from foreign (extern) static
fn main() {}
static FOO: i32 = [][0];
//~^ ERROR E0080
-//~| ERROR E0080
fn main() {
let array = [std::env::args().len()];
LL | static FOO: i32 = [][0];
| ^^^^^ index out of bounds: the len is 0 but the index is 0
-error[E0080]: could not evaluate static initializer
- --> $DIR/index_out_of_bounds.rs:11:1
- |
-LL | static FOO: i32 = [][0];
- | ^^^^^^^^^^^^^^^^^^-----^
- | |
- | index out of bounds: the len is 0 but the index is 0
-
error: index out of bounds: the len is 1 but the index is 1
- --> $DIR/index_out_of_bounds.rs:17:5
+ --> $DIR/index_out_of_bounds.rs:16:5
|
LL | array[1]; //~ ERROR index out of bounds
| ^^^^^^^^
|
= note: #[deny(const_err)] on by default
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.