::mir::interpret::EvalErrorKind::CheckMatchError |
::mir::interpret::EvalErrorKind::Layout(_) => return None,
::mir::interpret::EvalErrorKind::ReferencedConstant(ref inner) => {
- inner.struct_generic(tcx, "referenced constant", lint_root)?.emit();
+ inner.struct_generic(tcx, "referenced constant has errors", lint_root)?.emit();
},
_ => {},
}
) -> Option<Const<'tcx>> {
match c.literal {
Literal::Value { value } => {
- let v = self.use_ecx(source_info, |this| {
- this.ecx.const_to_value(value.val)
- })?;
- Some((v, value.ty, c.span))
+ self.ecx.tcx.span = source_info.span;
+ match self.ecx.const_to_value(value.val) {
+ Ok(val) => Some((val, value.ty, c.span)),
+ Err(error) => {
+ let (stacktrace, span) = self.ecx.generate_stacktrace(None);
+ let err = ConstEvalErr {
+ span,
+ error,
+ stacktrace,
+ };
+ err.report_as_error(
+ self.tcx.at(source_info.span),
+ "could not evaluate constant",
+ );
+ None
+ },
+ }
},
// evaluate the promoted and replace the constant with the evaluated result
Literal::Promoted { index } => {
fn main() {
black_box((FOO, FOO));
+ //~^ ERROR referenced constant has errors
+ //~| ERROR could not evaluate constant
}
LL | #![warn(const_err)]
| ^^^^^^^^^
-warning: referenced constant
+warning: referenced constant has errors
--> $DIR/conditional_array_execution.rs:19:20
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
LL | println!("{}", FOO);
| ^^^ referenced constant has errors
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/conditional_array_execution.rs:19:5
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/conditional_array_execution.rs:19:20
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
LL | #![warn(const_err)]
| ^^^^^^^^^
-warning: referenced constant
+warning: referenced constant has errors
--> $DIR/conditional_array_execution.rs:19:20
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
LL | println!("{}", FOO);
| ^^^ referenced constant has errors
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/conditional_array_execution.rs:19:20
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| |
| attempt to subtract with overflow
-warning: referenced constant
+warning: referenced constant has errors
--> $DIR/issue-43197.rs:24:23
|
LL | const X: u32 = 0-1;
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-warning: referenced constant
+warning: referenced constant has errors
--> $DIR/issue-43197.rs:24:26
|
LL | const Y: u32 = foo(0-1);
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-43197.rs:24:5
|
LL | const X: u32 = 0-1;
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-43197.rs:24:26
|
LL | const Y: u32 = foo(0-1);
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-43197.rs:24:23
|
LL | const X: u32 = 0-1;
| |
| attempt to subtract with overflow
-warning: referenced constant
+warning: referenced constant has errors
--> $DIR/issue-43197.rs:24:23
|
LL | const X: u32 = 0-1;
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-warning: referenced constant
+warning: referenced constant has errors
--> $DIR/issue-43197.rs:24:26
|
LL | const Y: u32 = foo(0-1);
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-43197.rs:24:26
|
LL | const Y: u32 = foo(0-1);
LL | println!("{} {}", X, Y);
| ^ referenced constant has errors
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-43197.rs:24:23
|
LL | const X: u32 = 0-1;
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-44578.rs:35:5
|
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-44578.rs:35:20
|
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-44578.rs:35:20
|
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-50814-2.rs:26:5
|
LL | const BAR: usize = [5, 6, 7][T::BOO];
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/issue-50814.rs:27:5
|
LL | const MAX: u8 = A::MAX + B::MAX;
let a: [i8; LEN] = unimplemented!();
//~^ ERROR E0080
//~| ERROR E0080
-//~| ERROR const_err
-//~| ERROR const_err
-//~| ERROR const_err
+//~| ERROR E0080
+//~| ERROR E0080
}
-error: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
LL | const LEN: usize = ONE - TWO;
...
LL | let a: [i8; LEN] = unimplemented!();
| ^^^
- |
- = note: #[deny(const_err)] on by default
-error: this expression will panic at runtime
+error[E0080]: could not evaluate constant
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^ referenced constant has errors
-error: referenced constant
- --> $DIR/const-len-underflow-separate-spans.rs:20:17
- |
-LL | const LEN: usize = ONE - TWO;
- | --------- attempt to subtract with overflow
-...
-LL | let a: [i8; LEN] = unimplemented!();
- | ^^^
-
-error[E0080]: referenced constant
+error[E0080]: referenced constant has errors
--> $DIR/const-len-underflow-separate-spans.rs:20:12
|
LL | const LEN: usize = ONE - TWO;
| |
| referenced constant has errors
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0080`.