Use the informative error as the main const eval error message

This commit is contained in:
Oli Scherer
2025-05-28 10:29:08 +00:00
parent e6152cdf5b
commit b331b8b96d
444 changed files with 4131 additions and 4298 deletions

View File

@@ -1,6 +1,6 @@
use std::mem;
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagArg};
use rustc_errors::{Diag, DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg};
use rustc_middle::mir::AssertKind;
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo};
use rustc_middle::query::TyCtxtAt;
@@ -131,10 +131,10 @@ pub fn get_span_and_frames<'tcx>(
/// Create a diagnostic for a const eval error.
///
/// This will use the `mk` function for creating the error which will get passed labels according to
/// the `InterpError` and the span and a stacktrace of current execution according to
/// `get_span_and_frames`.
pub(super) fn report<'tcx, C, F, E>(
/// This will use the `mk` function for adding more information to the error.
/// You can use it to add a stacktrace of current execution according to
/// `get_span_and_frames` or just give context on where the const eval error happened.
pub(super) fn report<'tcx, C, F>(
tcx: TyCtxt<'tcx>,
error: InterpErrorKind<'tcx>,
span: Span,
@@ -143,8 +143,7 @@ pub(super) fn report<'tcx, C, F, E>(
) -> ErrorHandled
where
C: FnOnce() -> (Span, Vec<FrameNote>),
F: FnOnce(Span, Vec<FrameNote>) -> E,
E: Diagnostic<'tcx>,
F: FnOnce(&mut Diag<'_>, Span, Vec<FrameNote>),
{
// Special handling for certain errors
match error {
@@ -163,8 +162,7 @@ where
_ => {
let (our_span, frames) = get_span_and_frames();
let span = span.substitute_dummy(our_span);
let err = mk(span, frames);
let mut err = tcx.dcx().create_err(err);
let mut err = tcx.dcx().struct_span_err(our_span, error.diagnostic_message());
// We allow invalid programs in infallible promoteds since invalid layouts can occur
// anyway (e.g. due to size overflow). And we allow OOM as that can happen any time.
let allowed_in_infallible = matches!(
@@ -172,11 +170,9 @@ where
InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_)
);
let msg = error.diagnostic_message();
error.add_args(&mut err);
// Use *our* span to label the interp error
err.span_label(our_span, msg);
mk(&mut err, span, frames);
let g = err.emit();
let reported = if allowed_in_infallible {
ReportedErrorInfo::allowed_in_infallible(g)

View File

@@ -2,6 +2,7 @@ use std::sync::atomic::Ordering::Relaxed;
use either::{Left, Right};
use rustc_abi::{self as abi, BackendRepr};
use rustc_errors::E0080;
use rustc_hir::def::DefKind;
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo, ReportedErrorInfo};
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
@@ -290,12 +291,18 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
|error| {
let span = tcx.def_span(def_id);
// FIXME(oli-obk): why don't we have any tests for this code path?
super::report(
tcx,
error.into_kind(),
span,
|| (span, vec![]),
|span, _| errors::NullaryIntrinsicError { span },
|diag, span, _| {
diag.span_label(
span,
crate::fluent_generated::const_eval_nullary_intrinsic_fail,
);
},
)
},
);
@@ -443,11 +450,15 @@ fn report_eval_error<'tcx>(
error,
DUMMY_SP,
|| super::get_span_and_frames(ecx.tcx, ecx.stack()),
|span, frames| errors::ConstEvalError {
span,
error_kind: kind,
instance,
frame_notes: frames,
|diag, span, frames| {
// FIXME(oli-obk): figure out how to use structured diagnostics again.
diag.code(E0080);
diag.span_label(span, crate::fluent_generated::const_eval_error);
diag.arg("instance", instance);
diag.arg("error_kind", kind);
for frame in frames {
diag.subdiagnostic(frame);
}
},
)
}
@@ -477,6 +488,15 @@ fn report_validation_error<'tcx>(
error,
DUMMY_SP,
|| crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()),
move |span, frames| errors::ValidationFailure { span, ub_note: (), frames, raw_bytes },
move |diag, span, frames| {
// FIXME(oli-obk): figure out how to use structured diagnostics again.
diag.code(E0080);
diag.span_label(span, crate::fluent_generated::const_eval_validation_failure);
diag.note(crate::fluent_generated::const_eval_validation_failure_note);
for frame in frames {
diag.subdiagnostic(frame);
}
diag.subdiagnostic(raw_bytes);
},
)
}

View File

@@ -439,38 +439,6 @@ pub struct LiveDrop<'tcx> {
pub dropped_at: Span,
}
#[derive(Diagnostic)]
#[diag(const_eval_error, code = E0080)]
pub struct ConstEvalError {
#[primary_span]
pub span: Span,
/// One of "const", "const_with_path", and "static"
pub error_kind: &'static str,
pub instance: String,
#[subdiagnostic]
pub frame_notes: Vec<FrameNote>,
}
#[derive(Diagnostic)]
#[diag(const_eval_nullary_intrinsic_fail)]
pub struct NullaryIntrinsicError {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(const_eval_validation_failure, code = E0080)]
pub struct ValidationFailure {
#[primary_span]
pub span: Span,
#[note(const_eval_validation_failure_note)]
pub ub_note: (),
#[subdiagnostic]
pub frames: Vec<FrameNote>,
#[subdiagnostic]
pub raw_bytes: RawBytesNote,
}
pub trait ReportErrorExt {
/// Returns the diagnostic message for this error.
fn diagnostic_message(&self) -> DiagMessage;

View File

@@ -68,7 +68,7 @@ fn main() {
// This should be linted, since `suppress-restriction-lint-in-const` default is false.
const { &ARR[idx4()] };
//~^ ERROR: indexing may panic
//~| ERROR: evaluation of `main
//~| ERROR: index out of bounds
let y = &x;
// Ok, referencing shouldn't affect this lint. See the issue 6021

View File

@@ -9,11 +9,11 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re
= note: `-D clippy::indexing-slicing` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
error[E0080]: evaluation of `main::{constant#3}` failed
error[E0080]: index out of bounds: the length is 2 but the index is 4
--> tests/ui/indexing_slicing_index.rs:69:14
|
LL | const { &ARR[idx4()] };
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
| ^^^^^^^^^^^ evaluation of `main::{constant#3}` failed
note: erroneous constant encountered
--> tests/ui/indexing_slicing_index.rs:69:5

View File

@@ -1,7 +1,7 @@
const UNALIGNED_READ: () = unsafe {
let x = &[0u8; 4];
let ptr = x.as_ptr().cast::<u32>();
ptr.read(); //~ERROR: evaluation of constant value failed
ptr.read(); //~ERROR: accessing memory based on pointer with alignment 1, but alignment 4 is required
};
fn main() {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required
--> tests/fail/const-ub-checks.rs:LL:CC
|
LL | ptr.read();
| ^^^^^^^^^^ accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required
| ^^^^^^^^^^ evaluation of constant value failed
note: erroneous constant encountered
--> tests/fail/const-ub-checks.rs:LL:CC

View File

@@ -4,7 +4,7 @@
struct PrintName<T>(T);
impl<T> PrintName<T> {
const VOID: ! = panic!(); //~ERROR: evaluation of `PrintName::<i32>::VOID` failed
const VOID: ! = panic!(); //~ERROR: explicit panic
}
fn no_codegen<T>() {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of `PrintName::<i32>::VOID` failed
error[E0080]: evaluation panicked: explicit panic
--> tests/fail/erroneous_const.rs:LL:CC
|
LL | const VOID: ! = panic!();
| ^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^ evaluation of `PrintName::<i32>::VOID` failed
note: erroneous constant encountered
--> tests/fail/erroneous_const.rs:LL:CC

View File

@@ -1,7 +1,7 @@
const X: u32 = 5;
const Y: u32 = 6;
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
//~^ERROR: evaluation of constant value failed
//~^ERROR: overflow
#[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391
fn main() {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow
--> tests/fail/erroneous_const2.rs:LL:CC
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow
| ^^^^^ evaluation of constant value failed
note: erroneous constant encountered
--> tests/fail/erroneous_const2.rs:LL:CC

View File

@@ -4,8 +4,8 @@ use std::cell::Cell;
use std::mem;
pub struct S {
s: Cell<usize>
s: Cell<usize>,
}
pub const N: usize = 0 - (mem::size_of::<S>() != 400) as usize;
//~^ ERROR evaluation of constant value failed
//~^ ERROR overflow

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
--> $DIR/const-evalutation-ice.rs:10:22
|
LL | pub const N: usize = 0 - (mem::size_of::<S>() != 400) as usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -1,7 +1,6 @@
const A: &'static [i32] = &[];
const B: i32 = (&A)[1];
//~^ NOTE index out of bounds: the length is 0 but the index is 1
//~| ERROR evaluation of constant value failed
//~^ ERROR index out of bounds: the length is 0 but the index is 1
fn main() {
let _ = B;

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: index out of bounds: the length is 0 but the index is 1
--> $DIR/array_const_index-0.rs:2:16
|
LL | const B: i32 = (&A)[1];
| ^^^^^^^ index out of bounds: the length is 0 but the index is 1
| ^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -1,7 +1,6 @@
const A: [i32; 0] = [];
const B: i32 = A[1];
//~^ NOTE index out of bounds: the length is 0 but the index is 1
//~| ERROR evaluation of constant value failed
//~^ ERROR index out of bounds: the length is 0 but the index is 1
fn main() {
let _ = B;

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: index out of bounds: the length is 0 but the index is 1
--> $DIR/array_const_index-1.rs:2:16
|
LL | const B: i32 = A[1];
| ^^^^ index out of bounds: the length is 0 but the index is 1
| ^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -1,14 +1,14 @@
error[E0080]: evaluation of `{global_asm#0}::{constant#0}` failed
error[E0080]: attempt to shift left by `500_i32`, which would overflow
--> $DIR/fail-const-eval-issue-121099.rs:8:31
|
LL | global_asm!("/* {} */", const 1 << 500);
| ^^^^^^^^ attempt to shift left by `500_i32`, which would overflow
| ^^^^^^^^ evaluation of `{global_asm#0}::{constant#0}` failed
error[E0080]: evaluation of `{global_asm#1}::{constant#0}` failed
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/fail-const-eval-issue-121099.rs:10:31
|
LL | global_asm!("/* {} */", const 1 / 0);
| ^^^^^ attempt to divide `1_i32` by zero
| ^^^^^ evaluation of `{global_asm#1}::{constant#0}` failed
error: aborting due to 2 previous errors

View File

@@ -7,7 +7,7 @@ trait Tr {
// This should not be a constant evaluation error (overflow). The value of
// `Self::A` must not be assumed to hold inside the trait.
const B: u8 = Self::A + 1;
//~^ ERROR evaluation of `<() as Tr>::B` failed
//~^ ERROR overflow
}
// An impl that doesn't override any constant will NOT cause a const eval error

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of `<() as Tr>::B` failed
error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
--> $DIR/defaults-not-assumed-fail.rs:9:19
|
LL | const B: u8 = Self::A + 1;
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
| ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed
note: erroneous constant encountered
--> $DIR/defaults-not-assumed-fail.rs:34:16

View File

@@ -3,7 +3,7 @@
//@ dont-require-annotations: NOTE
const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed
const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR explicit panic
//~^ NOTE constant
const fn f<F>(_: &[u8], _: F) -> &[u8]

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/issue-81899.rs:6:24
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^^^^^ evaluation of constant value failed
|
note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>`
--> $DIR/issue-81899.rs:13:5

View File

@@ -2,7 +2,7 @@
//@ dont-require-annotations: NOTE
const _CONST: &() = &f(&|_| {}); //~ ERROR evaluation of constant value failed
const _CONST: &() = &f(&|_| {}); //~ ERROR explicit panic
//~^ NOTE constant
const fn f<F>(_: &F)

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/issue-88434-minimal-example.rs:5:22
|
LL | const _CONST: &() = &f(&|_| {});
| ^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^ evaluation of constant value failed
|
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>`
--> $DIR/issue-88434-minimal-example.rs:12:5

View File

@@ -2,7 +2,7 @@
//@ dont-require-annotations: NOTE
const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed
const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR explicit panic
//~^ NOTE constant
const fn f<F>(_: &[u8], _: F) -> &[u8]

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/issue-88434-removal-index-should-be-less.rs:5:24
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^^^^^ evaluation of constant value failed
|
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>`
--> $DIR/issue-88434-removal-index-should-be-less.rs:12:5

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: Some error occurred
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
|
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
| ^^^^^^^^ evaluation panicked: Some error occurred
| ^^^^^^^^ evaluation of constant value failed
|
note: inside `my_fn`
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
@@ -10,11 +10,11 @@ note: inside `my_fn`
LL | panic!("Some error occurred");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: Some error occurred
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
|
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
| ^^^^^^^^ evaluation panicked: Some error occurred
| ^^^^^^^^ evaluation of constant value failed
|
note: inside `my_fn`
--> $DIR/const-errs-dont-conflict-103369.rs:10:5

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
--> $DIR/default-param-wf-concrete.rs:4:28
|
LL | struct Foo<const N: u8 = { 255 + 1 }>;
| ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
| ^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
--> $DIR/default-param-wf-concrete.rs:4:28
|
LL | struct Foo<const N: u8 = { 255 + 1 }>;
| ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
| ^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -2,5 +2,5 @@
//@[next] compile-flags: -Znext-solver
struct Foo<const N: u8 = { 255 + 1 }>;
//~^ ERROR evaluation of constant value failed
//~^ ERROR overflow
fn main() {}

View File

@@ -1,5 +1,5 @@
struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
//~^ error: evaluation of constant value failed
//~^ error: overflow
trait Trait<const N: u8> {}
impl Trait<3> for () {}

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
--> $DIR/wfness.rs:1:33
|
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0277]: the trait bound `(): Trait<2>` is not satisfied
--> $DIR/wfness.rs:8:9

View File

@@ -2,7 +2,7 @@
#![allow(incomplete_features)]
fn test<const N: usize>() -> [u8; N - 1] {
//~^ ERROR evaluation of `test::<0>::{constant#0}` failed
//~^ ERROR overflow
todo!()
}

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of `test::<0>::{constant#0}` failed
error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
--> $DIR/from-sig-fail.rs:4:35
|
LL | fn test<const N: usize>() -> [u8; N - 1] {
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
| ^^^^^ evaluation of `test::<0>::{constant#0}` failed
error: aborting due to 1 previous error

View File

@@ -2,12 +2,12 @@
#![allow(incomplete_features)]
type Arr<const N: usize> = [u8; N - 1];
//~^ ERROR evaluation of `Arr::<0>::{constant#0}` failed
//~^ ERROR overflow
fn test<const N: usize>() -> Arr<N>
where
[u8; N - 1]: Sized,
//~^ ERROR evaluation of `test::<0>::{constant#0}` failed
//~^ ERROR overflow
{
todo!()
}

View File

@@ -1,14 +1,14 @@
error[E0080]: evaluation of `test::<0>::{constant#0}` failed
error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
--> $DIR/simple_fail.rs:9:10
|
LL | [u8; N - 1]: Sized,
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
| ^^^^^ evaluation of `test::<0>::{constant#0}` failed
error[E0080]: evaluation of `Arr::<0>::{constant#0}` failed
error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
--> $DIR/simple_fail.rs:4:33
|
LL | type Arr<const N: usize> = [u8; N - 1];
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
| ^^^^^ evaluation of `Arr::<0>::{constant#0}` failed
error: aborting due to 2 previous errors

View File

@@ -15,7 +15,7 @@ impl<const B: &'static bool> T<B> {
const _: () = {
let x = T::<{ &true }>;
x.set_false(); //~ ERROR evaluation of constant value failed [E0080]
x.set_false(); //~ ERROR writing to ALLOC0 which is read-only
};
fn main() {}

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: writing to ALLOC0 which is read-only
--> $DIR/issue-100313.rs:18:5
|
LL | x.set_false();
| ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only
| ^^^^^^^^^^^^^ evaluation of constant value failed
|
note: inside `T::<&true>::set_false`
--> $DIR/issue-100313.rs:11:13

View File

@@ -1,36 +1,36 @@
error[E0080]: evaluation of constant value failed
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/invalid-patterns.rs:40:32
|
LL | get_flag::<false, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:43:14
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
--> $DIR/invalid-patterns.rs:42:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 1, align: 1) {
42 │ B
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:45:14
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
--> $DIR/invalid-patterns.rs:44:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 1, align: 1) {
42 │ B
}
error[E0080]: evaluation of constant value failed
--> $DIR/invalid-patterns.rs:45:58
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/invalid-patterns.rs:44:58
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:31:21

View File

@@ -1,36 +1,36 @@
error[E0080]: evaluation of constant value failed
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/invalid-patterns.rs:40:32
|
LL | get_flag::<false, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:43:14
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
--> $DIR/invalid-patterns.rs:42:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 1, align: 1) {
42 │ B
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:45:14
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
--> $DIR/invalid-patterns.rs:44:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 1, align: 1) {
42 │ B
}
error[E0080]: evaluation of constant value failed
--> $DIR/invalid-patterns.rs:45:58
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/invalid-patterns.rs:44:58
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:31:21

View File

@@ -38,12 +38,10 @@ fn main() {
get_flag::<false, { unsafe { char_raw.character } }>();
//~^ ERROR evaluation of constant value failed
//~| NOTE uninitialized
//~^ ERROR uninitialized
get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
//~^ ERROR it is undefined behavior
//~^ ERROR 0x42, but expected a boolean
get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
//~^ ERROR evaluation of constant value failed
//~| NOTE uninitialized
//~| ERROR it is undefined behavior
//~^ ERROR uninitialized
//~| ERROR 0x42, but expected a boolean
}

View File

@@ -14,24 +14,24 @@ use std::{
// Null is never valid for references
pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: null reference
pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: null reference
// Out of bounds
pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: dangling reference (going beyond the bounds of its allocation)
// Reading uninitialized data
pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: it is undefined behavior to use this value
pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; //~ ERROR: uninitialized memory
// Reinterpret pointers as integers (UB in CTFE.)
pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; //~ ERROR: it is undefined behavior to use this value
pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; //~ ERROR: pointer, but expected an integer
// Layout mismatch
pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; //~ ERROR: it is undefined behavior to use this value
pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; //~ ERROR: 0x11, but expected a boolean
// Reading padding is not ok
pub static S7: &[u16] = unsafe {
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: uninitialized memory
let ptr = (&D2 as *const Struct as *const u16).add(1);
from_raw_parts(ptr, 4)
@@ -39,53 +39,53 @@ pub static S7: &[u16] = unsafe {
// Unaligned read
pub static S8: &[u64] = unsafe {
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: dangling reference (going beyond the bounds of its allocation)
let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>();
from_raw_parts(ptr, 1)
};
pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
//~^ ERROR it is undefined behavior to use this value
//~^ ERROR encountered a null reference
pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
//~^ ERROR could not evaluate static initializer
//~^ ERROR 0 < pointee_size && pointee_size <= isize::MAX as usize
pub static R2: &[u32] = unsafe {
let ptr = &D0 as *const u32;
from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
//~^ ERROR could not evaluate static initializer
//~^ ERROR in-bounds pointer arithmetic failed
};
pub static R4: &[u8] = unsafe {
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: encountered uninitialized memory, but expected an integer
let ptr = (&D1) as *const MaybeUninit<&u32> as *const u8;
from_ptr_range(ptr..ptr.add(1))
};
pub static R5: &[u8] = unsafe {
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: encountered a pointer, but expected an integer
let ptr = &D3 as *const &u32;
from_ptr_range(ptr.cast()..ptr.add(1).cast())
};
pub static R6: &[bool] = unsafe {
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: 0x11, but expected a boolean
let ptr = &D0 as *const u32 as *const bool;
from_ptr_range(ptr..ptr.add(4))
};
pub static R7: &[u16] = unsafe {
//~^ ERROR: it is undefined behavior to use this value
//~^ ERROR: unaligned reference (required 2 byte alignment but found 1)
let ptr = (&D2 as *const Struct as *const u16).byte_add(1);
from_ptr_range(ptr..ptr.add(4))
};
pub static R8: &[u64] = unsafe {
let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>();
from_ptr_range(ptr..ptr.add(1))
//~^ ERROR could not evaluate static initializer
//~^ ERROR in-bounds pointer arithmetic failed
};
// This is sneaky: &D0 and &D0 point to different objects
// (even if at runtime they have the same address)
pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
//~^ ERROR could not evaluate static initializer
//~^ ERROR not both derived from the same allocation
pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
//~^ ERROR could not evaluate static initializer
//~^ ERROR not both derived from the same allocation
const D0: u32 = 0x11111111; // Constant chosen for endianness-independent behavior.
const D1: MaybeUninit<&u32> = MaybeUninit::uninit();

View File

@@ -1,179 +1,179 @@
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value: encountered a null reference
--> $DIR/forbidden_slices.rs:16:1
|
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
| ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value: encountered a null reference
--> $DIR/forbidden_slices.rs:18:1
|
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
| ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
--> $DIR/forbidden_slices.rs:22:1
|
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
| ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
--> $DIR/forbidden_slices.rs:26:1
|
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
| ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
--> $DIR/forbidden_slices.rs:28:1
|
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
| ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
--> $DIR/forbidden_slices.rs:30:1
|
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
| ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
--> $DIR/forbidden_slices.rs:33:1
|
LL | pub static S7: &[u16] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
| ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
--> $DIR/forbidden_slices.rs:41:1
|
LL | pub static S8: &[u64] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
| ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value: encountered a null reference
--> $DIR/forbidden_slices.rs:48:1
|
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
| ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: could not evaluate static initializer
error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize
--> $DIR/forbidden_slices.rs:50:33
|
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
error[E0080]: could not evaluate static initializer
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
--> $DIR/forbidden_slices.rs:54:25
|
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
| ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
| ^^^^^^^^^^ could not evaluate static initializer
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
--> $DIR/forbidden_slices.rs:57:1
|
LL | pub static R4: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
| ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
--> $DIR/forbidden_slices.rs:62:1
|
LL | pub static R5: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
| ^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
--> $DIR/forbidden_slices.rs:67:1
|
LL | pub static R6: &[bool] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
| ^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: it is undefined behavior to use this value
error[E0080]: constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
--> $DIR/forbidden_slices.rs:72:1
|
LL | pub static R7: &[u16] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
| ^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
error[E0080]: could not evaluate static initializer
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
--> $DIR/forbidden_slices.rs:79:25
|
LL | from_ptr_range(ptr..ptr.add(1))
| ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
| ^^^^^^^^^^ could not evaluate static initializer
error[E0080]: could not evaluate static initializer
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
--> $DIR/forbidden_slices.rs:85:34
|
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
error[E0080]: could not evaluate static initializer
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
--> $DIR/forbidden_slices.rs:87:35
|
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
| ^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
error: aborting due to 18 previous errors

View File

@@ -6,9 +6,9 @@ fn main() {
const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) };
const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
//~^ ERROR evaluation of constant value failed
//~^ ERROR at or beyond the end of the allocation
const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
//~^ ERROR evaluation of constant value failed
//~^ ERROR at or beyond the end of the allocation
const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
//~^ ERROR evaluation of constant value failed
//~^ ERROR at or beyond the end of the allocation
}

View File

@@ -1,20 +1,20 @@
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
--> $DIR/out_of_bounds_read.rs:8:33
|
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
| ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
--> $DIR/out_of_bounds_read.rs:10:39
|
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
| ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
| ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
--> $DIR/out_of_bounds_read.rs:12:37
|
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 3 previous errors

View File

@@ -9,14 +9,14 @@ fn main() {
const _BAD1: () = unsafe {
MaybeUninit::<!>::uninit().assume_init();
//~^ERROR: evaluation of constant value failed
//~^ERROR: uninhabited
};
const _BAD2: () = {
intrinsics::assert_mem_uninitialized_valid::<&'static i32>();
//~^ERROR: evaluation of constant value failed
//~^ERROR: uninitialized
};
const _BAD3: () = {
intrinsics::assert_zero_valid::<&'static i32>();
//~^ERROR: evaluation of constant value failed
//~^ERROR: zero-initialize type `&i32`
};
}

View File

@@ -1,20 +1,20 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!`
--> $DIR/assert-type-intrinsics.rs:11:9
|
LL | MaybeUninit::<!>::uninit().assume_init();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid
--> $DIR/assert-type-intrinsics.rs:15:9
|
LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid
--> $DIR/assert-type-intrinsics.rs:19:9
|
LL | intrinsics::assert_zero_valid::<&'static i32>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 3 previous errors

View File

@@ -6,7 +6,7 @@ trait ZeroSized: Sized {
}
impl<T: Sized> ZeroSized for T {
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR index out of bounds: the length is 1 but the index is 4
fn requires_zero_size(self) {
Self::I_AM_ZERO_SIZED;
println!("requires_zero_size called");

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
--> $DIR/assoc_const_generic_impl.rs:9:34
error[E0080]: index out of bounds: the length is 1 but the index is 4
--> $DIR/assoc_const_generic_impl.rs:9:33
|
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
note: erroneous constant encountered
--> $DIR/assoc_const_generic_impl.rs:11:9

View File

@@ -1,11 +1,9 @@
const FOO: [usize; 3] = [1, 2, 3];
const BAR: usize = FOO[5];
//~^ ERROR: evaluation of constant value failed
//~| NOTE index out of bounds: the length is 3 but the index is 5
//~^ ERROR: index out of bounds: the length is 3 but the index is 5
const BLUB: [u32; FOO[4]] = [5, 6];
//~^ ERROR evaluation of constant value failed [E0080]
//~| NOTE index out of bounds: the length is 3 but the index is 4
//~^ ERROR index out of bounds: the length is 3 but the index is 4
fn main() {
let _ = BAR;

View File

@@ -1,14 +1,14 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const-array-oob.rs:6:19
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/const-array-oob.rs:5:19
|
LL | const BLUB: [u32; FOO[4]] = [5, 6];
| ^^^^^^ index out of bounds: the length is 3 but the index is 4
| ^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: index out of bounds: the length is 3 but the index is 5
--> $DIR/const-array-oob.rs:2:20
|
LL | const BAR: usize = FOO[5];
| ^^^^^^ index out of bounds: the length is 3 but the index is 5
| ^^^^^^ evaluation of constant value failed
error: aborting due to 2 previous errors

View File

@@ -1,6 +1,6 @@
const _: () = unsafe {
let n = u32::MAX.count_ones();
std::hint::assert_unchecked(n < 32); //~ ERROR evaluation of constant value failed
std::hint::assert_unchecked(n < 32); //~ ERROR `assume` called with `false`
};
fn main() {}

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: `assume` called with `false`
--> $DIR/const-assert-unchecked-ub.rs:3:5
|
LL | std::hint::assert_unchecked(n < 32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -7,34 +7,34 @@ use std::mem::MaybeUninit;
fn main() {
const LHS_NULL: i32 = unsafe {
compare_bytes(0 as *const u8, 2 as *const u8, 1)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory access failed
};
const RHS_NULL: i32 = unsafe {
compare_bytes(1 as *const u8, 0 as *const u8, 1)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory access failed
};
const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe {
compare_bytes(1 as *const u8, 2 as *const u8, 1)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory access failed
};
const LHS_OUT_OF_BOUNDS: i32 = unsafe {
compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory access failed
};
const RHS_OUT_OF_BOUNDS: i32 = unsafe {
compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory access failed
};
const LHS_UNINIT: i32 = unsafe {
compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory is uninitialized
};
const RHS_UNINIT: i32 = unsafe {
compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1)
//~^ ERROR evaluation of constant value failed
//~^ ERROR memory is uninitialized
};
const WITH_PROVENANCE: i32 = unsafe {
compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>())
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
};
}

View File

@@ -1,50 +1,50 @@
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 1 byte, but got null pointer
--> $DIR/const-compare-bytes-ub.rs:9:9
|
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got null pointer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/const-compare-bytes-ub.rs:13:9
|
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/const-compare-bytes-ub.rs:17:9
|
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation
--> $DIR/const-compare-bytes-ub.rs:21:9
|
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation
--> $DIR/const-compare-bytes-ub.rs:25:9
|
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
--> $DIR/const-compare-bytes-ub.rs:29:9
|
LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
--> $DIR/const-compare-bytes-ub.rs:33:9
|
LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: unable to turn pointer into integer
--> $DIR/const-compare-bytes-ub.rs:37:9
|
LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported

View File

@@ -2,7 +2,6 @@
fn main() {
static C: u64 = unsafe { *(0xdeadbeef as *const u64) };
//~^ ERROR could not evaluate static initializer
//~| NOTE dangling pointer
//~^ ERROR dangling pointer
println!("{}", C);
}

View File

@@ -1,8 +1,8 @@
error[E0080]: could not evaluate static initializer
--> $DIR/const-deref-ptr.rs:4:29
error[E0080]: memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/const-deref-ptr.rs:4:30
|
LL | static C: u64 = unsafe { *(0xdeadbeef as *const u64) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
error: aborting due to 1 previous error

View File

@@ -1,8 +1,8 @@
pub const A: i8 = -i8::MIN; //~ ERROR constant
pub const B: u8 = 200u8 + 200u8; //~ ERROR constant
pub const C: u8 = 200u8 * 4; //~ ERROR constant
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR constant
pub const E: u8 = [5u8][1]; //~ ERROR constant
pub const A: i8 = -i8::MIN; //~ ERROR overflow
pub const B: u8 = 200u8 + 200u8; //~ ERROR overflow
pub const C: u8 = 200u8 * 4; //~ ERROR overflow
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR overflow
pub const E: u8 = [5u8][1]; //~ ERROR index out of bounds
fn main() {
let _a = A;

View File

@@ -1,32 +1,32 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to negate `i8::MIN`, which would overflow
--> $DIR/const-err-early.rs:1:19
|
LL | pub const A: i8 = -i8::MIN;
| ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
| ^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `200_u8 + 200_u8`, which would overflow
--> $DIR/const-err-early.rs:2:19
|
LL | pub const B: u8 = 200u8 + 200u8;
| ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow
| ^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `200_u8 * 4_u8`, which would overflow
--> $DIR/const-err-early.rs:3:19
|
LL | pub const C: u8 = 200u8 * 4;
| ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow
| ^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `42_u8 - 43_u8`, which would overflow
--> $DIR/const-err-early.rs:4:19
|
LL | pub const D: u8 = 42u8 - (42u8 + 1);
| ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow
| ^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: index out of bounds: the length is 1 but the index is 1
--> $DIR/const-err-early.rs:5:19
|
LL | pub const E: u8 = [5u8][1];
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
| ^^^^^^^^ evaluation of constant value failed
error: aborting due to 5 previous errors

View File

@@ -6,8 +6,7 @@ union Foo {
enum Bar {
Boo = [unsafe { Foo { b: () }.a }; 4][3],
//~^ ERROR evaluation of constant value failed
//~| NOTE uninitialized
//~^ ERROR uninitialized
}
fn main() {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/const-err-enum-discriminant.rs:8:21
|
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
| ^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -12,8 +12,8 @@ struct S<T>(T);
impl<T> S<T> {
const FOO: u8 = [5u8][1];
//~^ ERROR evaluation of `S::<i32>::FOO` failed
//~| ERROR evaluation of `S::<u32>::FOO` failed
//~^ ERROR index out of bounds: the length is 1 but the index is 1
//~| ERROR index out of bounds: the length is 1 but the index is 1
}
fn main() {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of `S::<i32>::FOO` failed
error[E0080]: index out of bounds: the length is 1 but the index is 1
--> $DIR/const-err-late.rs:14:21
|
LL | const FOO: u8 = [5u8][1];
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
| ^^^^^^^^ evaluation of `S::<i32>::FOO` failed
note: erroneous constant encountered
--> $DIR/const-err-late.rs:20:16
@@ -10,11 +10,11 @@ note: erroneous constant encountered
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
| ^^^^^^^^^^^^^
error[E0080]: evaluation of `S::<u32>::FOO` failed
error[E0080]: index out of bounds: the length is 1 but the index is 1
--> $DIR/const-err-late.rs:14:21
|
LL | const FOO: u8 = [5u8][1];
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
| ^^^^^^^^ evaluation of `S::<u32>::FOO` failed
note: erroneous constant encountered
--> $DIR/const-err-late.rs:20:31

View File

@@ -1,6 +1,6 @@
pub const A: i8 = -i8::MIN;
//~^ ERROR constant
//~| NOTE attempt to negate `i8::MIN`, which would overflow
//~^ NOTE constant
//~| ERROR attempt to negate `i8::MIN`, which would overflow
pub const B: i8 = A;
//~^ NOTE constant
pub const C: u8 = A as u8;

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to negate `i8::MIN`, which would overflow
--> $DIR/const-err-multi.rs:1:19
|
LL | pub const A: i8 = -i8::MIN;
| ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
| ^^^^^^^^ evaluation of constant value failed
note: erroneous constant encountered
--> $DIR/const-err-multi.rs:4:19

View File

@@ -2,7 +2,7 @@
struct B<
A: Sized = [(); {
let x = [0u8; !0usize];
//~^ ERROR evaluation of constant value failed
//~^ ERROR too big for the target architecture
1
}],
> {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
--> $DIR/const-eval-fail-too-big.rs:4:28
|
LL | let x = [0u8; !0usize];
| ^^^^^^^^^^^^^^ values of the type `[u8; usize::MAX]` are too big for the target architecture
| ^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -6,7 +6,7 @@ use std::cell::UnsafeCell;
static mut FOO: u32 = 42;
static BOO: () = unsafe {
FOO = 5;
//~^ ERROR could not evaluate static initializer [E0080]
//~^ ERROR modifying a static's initial value
};
fn main() {}

View File

@@ -1,8 +1,8 @@
error[E0080]: could not evaluate static initializer
error[E0080]: modifying a static's initial value from another static's initializer
--> $DIR/assign-to-static-within-other-static.rs:8:5
|
LL | FOO = 5;
| ^^^^^^^ modifying a static's initial value from another static's initializer
| ^^^^^^^ could not evaluate static initializer
error: aborting due to 1 previous error

View File

@@ -1,7 +1,7 @@
const X: u32 = 5;
const Y: u32 = 6;
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
//~^ ERROR constant
//~^ ERROR overflow
fn main() {
println!("{}", FOO);

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow
--> $DIR/conditional_array_execution.rs:3:19
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
| ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow
| ^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -8,7 +8,7 @@ use std::{i8, i16, i32, i64, isize};
use std::{u8, u16, u32, u64, usize};
const NEG_128: i8 = -128;
const NEG_NEG_128: i8 = -NEG_128; //~ ERROR constant
const NEG_NEG_128: i8 = -NEG_128; //~ ERROR overflow
fn main() {
match -128i8 {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to negate `i8::MIN`, which would overflow
--> $DIR/const-eval-overflow-2.rs:11:25
|
LL | const NEG_NEG_128: i8 = -NEG_128;
| ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
| ^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -16,7 +16,7 @@ use std::fmt;
const A_I8_I
: [u32; (i8::MAX as usize) + 1]
= [0; (i8::MAX + 1) as usize];
//~^ ERROR evaluation of constant value failed
//~^ ERROR overflow
fn main() {
foo(&A_I8_I[..]);

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow
--> $DIR/const-eval-overflow-3.rs:18:11
|
LL | = [0; (i8::MAX + 1) as usize];
| ^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow
| ^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -9,7 +9,7 @@ use std::fmt;
const A_I8_T
: [u32; (i8::MAX as i8 + 1i8) as usize]
//~^ ERROR evaluation of constant value failed
//~^ ERROR overflow
= [0; (i8::MAX as usize) + 1];
fn main() {

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow
--> $DIR/const-eval-overflow-4.rs:11:13
|
LL | : [u32; (i8::MAX as i8 + 1i8) as usize]
| ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow
| ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -11,47 +11,47 @@ const VALS_I8: (i8,) =
(
i8::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I16: (i16,) =
(
i16::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I32: (i32,) =
(
i32::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I64: (i64,) =
(
i64::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U8: (u8,) =
(
u8::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U16: (u16,) = (
u16::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U32: (u32,) = (
u32::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U64: (u64,) =
(
u64::MIN - 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
fn main() {
foo(VALS_I8);

View File

@@ -1,50 +1,50 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i8::MIN - 1_i8`, which would overflow
--> $DIR/const-eval-overflow2.rs:12:6
|
LL | i8::MIN - 1,
| ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow
--> $DIR/const-eval-overflow2.rs:18:6
|
LL | i16::MIN - 1,
| ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow
--> $DIR/const-eval-overflow2.rs:24:6
|
LL | i32::MIN - 1,
| ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow
--> $DIR/const-eval-overflow2.rs:30:6
|
LL | i64::MIN - 1,
| ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow
--> $DIR/const-eval-overflow2.rs:36:6
|
LL | u8::MIN - 1,
| ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow
--> $DIR/const-eval-overflow2.rs:41:6
|
LL | u16::MIN - 1,
| ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow
--> $DIR/const-eval-overflow2.rs:46:6
|
LL | u32::MIN - 1,
| ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow
--> $DIR/const-eval-overflow2.rs:52:6
|
LL | u64::MIN - 1,
| ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 8 previous errors

View File

@@ -11,47 +11,47 @@ const VALS_I8: (i8,) =
(
i8::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I16: (i16,) =
(
i16::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I32: (i32,) =
(
i32::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I64: (i64,) =
(
i64::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U8: (u8,) =
(
u8::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U16: (u16,) = (
u16::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U32: (u32,) = (
u32::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U64: (u64,) =
(
u64::MAX + 1,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
fn main() {
foo(VALS_I8);

View File

@@ -1,50 +1,50 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow
--> $DIR/const-eval-overflow2b.rs:12:6
|
LL | i8::MAX + 1,
| ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow
--> $DIR/const-eval-overflow2b.rs:18:6
|
LL | i16::MAX + 1,
| ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow
--> $DIR/const-eval-overflow2b.rs:24:6
|
LL | i32::MAX + 1,
| ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow
--> $DIR/const-eval-overflow2b.rs:30:6
|
LL | i64::MAX + 1,
| ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
--> $DIR/const-eval-overflow2b.rs:36:6
|
LL | u8::MAX + 1,
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow
--> $DIR/const-eval-overflow2b.rs:41:6
|
LL | u16::MAX + 1,
| ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow
--> $DIR/const-eval-overflow2b.rs:46:6
|
LL | u32::MAX + 1,
| ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow
--> $DIR/const-eval-overflow2b.rs:52:6
|
LL | u64::MAX + 1,
| ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 8 previous errors

View File

@@ -11,47 +11,47 @@ const VALS_I8: (i8,) =
(
i8::MIN * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I16: (i16,) =
(
i16::MIN * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I32: (i32,) =
(
i32::MIN * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_I64: (i64,) =
(
i64::MIN * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U8: (u8,) =
(
u8::MAX * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U16: (u16,) = (
u16::MAX * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U32: (u32,) = (
u32::MAX * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
const VALS_U64: (u64,) =
(
u64::MAX * 2,
);
//~^^ ERROR evaluation of constant value failed
//~^^ ERROR overflow
fn main() {
foo(VALS_I8);

View File

@@ -1,50 +1,50 @@
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i8::MIN * 2_i8`, which would overflow
--> $DIR/const-eval-overflow2c.rs:12:6
|
LL | i8::MIN * 2,
| ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow
--> $DIR/const-eval-overflow2c.rs:18:6
|
LL | i16::MIN * 2,
| ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow
--> $DIR/const-eval-overflow2c.rs:24:6
|
LL | i32::MIN * 2,
| ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow
--> $DIR/const-eval-overflow2c.rs:30:6
|
LL | i64::MIN * 2,
| ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow
--> $DIR/const-eval-overflow2c.rs:36:6
|
LL | u8::MAX * 2,
| ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow
| ^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow
--> $DIR/const-eval-overflow2c.rs:41:6
|
LL | u16::MAX * 2,
| ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow
--> $DIR/const-eval-overflow2c.rs:46:6
|
LL | u32::MAX * 2,
| ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow
--> $DIR/const-eval-overflow2c.rs:52:6
|
LL | u64::MAX * 2,
| ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow
| ^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 8 previous errors

View File

@@ -13,7 +13,7 @@
//@ normalize-stderr: ".*omitted \d{1,} frame.*\n" -> ""
#![allow(unconditional_panic)]
const X: i32 = 1 / 0; //~ERROR constant
const X: i32 = 1 / 0; //~ERROR attempt to divide `1_i32` by zero
fn main() {
let x: &'static i32 = &X;

View File

@@ -1,8 +1,8 @@
error: internal compiler error[E0080]: evaluation of constant value failed
error: internal compiler error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/const-eval-query-stack.rs:16:16
|
LL | const X: i32 = 1 / 0;
| ^^^^^ attempt to divide `1_i32` by zero
| ^^^^^ evaluation of constant value failed
note: please make sure that you have updated to the latest nightly

View File

@@ -1,254 +1,254 @@
error[E0080]: evaluation of constant value failed
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:27:49
|
LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:30:43
|
LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:33:45
|
LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:36:45
|
LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:39:45
|
LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/const-pointer-values-in-various-types.rs:42:47
|
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:46:43
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:45:43
|
LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:49:45
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:48:45
|
LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:52:45
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:51:45
|
LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:55:45
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:54:45
|
LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:58:47
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/const-pointer-values-in-various-types.rs:57:47
|
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:62:45
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:60:45
|
LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:65:45
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:63:45
|
LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:68:47
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:66:47
|
LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:71:47
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:69:47
|
LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:74:39
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:72:39
|
LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:77:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:75:41
|
LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:80:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:78:41
|
LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:83:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:81:41
|
LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:86:43
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:84:43
|
LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:89:39
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:87:39
|
LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:92:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:90:41
|
LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:95:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:93:41
|
LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:98:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:96:41
|
LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:101:43
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:99:43
|
LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:104:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:102:41
|
LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:107:41
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:105:41
|
LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:110:43
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:108:43
|
LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:113:43
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:111:43
|
LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported

View File

@@ -25,91 +25,89 @@ union Nonsense {
fn main() {
const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
//~^ ERROR evaluation of constant value failed
//~| NOTE uninitialized
//~^ ERROR uninitialized
const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
//~^ ERROR evaluation of constant value failed
//~| NOTE uninitialized
//~^ ERROR uninitialized
const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
//~^ ERROR evaluation of constant value failed
//~^ ERROR unable to turn pointer into integer
}

View File

@@ -14,11 +14,11 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
}
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
//~^ ERROR evaluation of constant value failed
//~| NOTE calling non-const function `double`
//~^ NOTE evaluation of constant value failed
//~| ERROR calling non-const function `double`
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
//~^ ERROR evaluation of constant value failed
//~| NOTE calling non-const function `double`
//~^ NOTE evaluation of constant value failed
//~| ERROR calling non-const function `double`
fn main() {
assert_eq!(Y, 4);

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: calling non-const function `double`
--> $DIR/const_fn_ptr_fail2.rs:16:18
|
LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
| ^^^^^^^^^ calling non-const function `double`
| ^^^^^^^^^ evaluation of constant value failed
|
note: inside `bar`
--> $DIR/const_fn_ptr_fail2.rs:9:5
@@ -10,11 +10,11 @@ note: inside `bar`
LL | x(y)
| ^^^^ the failure occurred here
error[E0080]: evaluation of constant value failed
error[E0080]: calling non-const function `double`
--> $DIR/const_fn_ptr_fail2.rs:19:18
|
LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
| ^^^^^^^^^^^^^^ calling non-const function `double`
| ^^^^^^^^^^^^^^ evaluation of constant value failed
|
note: inside `bar`
--> $DIR/const_fn_ptr_fail2.rs:9:5

View File

@@ -1,5 +1,5 @@
#![crate_type = "lib"]
struct Bug([u8; panic!{"\t"}]);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
//~| NOTE: in this expansion of panic!

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked:
--> $DIR/const_panic-normalize-tabs-115498.rs:3:17
|
LL | struct Bug([u8; panic!{"\t"}]);
| ^^^^^^^^^^^^ evaluation panicked:
| ^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 1 previous error

View File

@@ -4,37 +4,37 @@
const MSG: &str = "hello";
const Z: () = std::panic!("cheese");
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const Z2: () = std::panic!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const Y: () = std::unreachable!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const X: () = std::unimplemented!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const W: () = std::panic!(MSG);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const W2: () = std::panic!("{}", MSG);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const Z_CORE: () = core::panic!("cheese");
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const Z2_CORE: () = core::panic!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const Y_CORE: () = core::unreachable!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const X_CORE: () = core::unimplemented!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const W_CORE: () = core::panic!(MSG);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const W2_CORE: () = core::panic!("{}", MSG);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked

View File

@@ -1,78 +1,78 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: cheese
--> $DIR/const_panic.rs:6:15
|
LL | const Z: () = std::panic!("cheese");
| ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese
| ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic.rs:9:16
|
LL | const Z2: () = std::panic!();
| ^^^^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic.rs:12:15
|
LL | const Y: () = std::unreachable!();
| ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code
| ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic.rs:15:15
|
LL | const X: () = std::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented
| ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic.rs:18:15
|
LL | const W: () = std::panic!(MSG);
| ^^^^^^^^^^^^^^^^ evaluation panicked: hello
| ^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic.rs:21:16
|
LL | const W2: () = std::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: cheese
--> $DIR/const_panic.rs:24:20
|
LL | const Z_CORE: () = core::panic!("cheese");
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic.rs:27:21
|
LL | const Z2_CORE: () = core::panic!();
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic.rs:30:20
|
LL | const Y_CORE: () = core::unreachable!();
| ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code
| ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic.rs:33:20
|
LL | const X_CORE: () = core::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic.rs:36:20
|
LL | const W_CORE: () = core::panic!(MSG);
| ^^^^^^^^^^^^^^^^^ evaluation panicked: hello
| ^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic.rs:39:21
|
LL | const W2_CORE: () = core::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 12 previous errors

View File

@@ -4,31 +4,31 @@
const MSG: &str = "hello";
const A: () = std::panic!("blåhaj");
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const B: () = std::panic!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const C: () = std::unreachable!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const D: () = std::unimplemented!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const E: () = std::panic!("{}", MSG);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const A_CORE: () = core::panic!("shark");
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const B_CORE: () = core::panic!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const C_CORE: () = core::unreachable!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const D_CORE: () = core::unimplemented!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const E_CORE: () = core::panic!("{}", MSG);
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked

View File

@@ -1,66 +1,66 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: blåhaj
--> $DIR/const_panic_2021.rs:6:15
|
LL | const A: () = std::panic!("blåhaj");
| ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: blåhaj
| ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic_2021.rs:9:15
|
LL | const B: () = std::panic!();
| ^^^^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic_2021.rs:12:15
|
LL | const C: () = std::unreachable!();
| ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code
| ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic_2021.rs:15:15
|
LL | const D: () = std::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented
| ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic_2021.rs:18:15
|
LL | const E: () = std::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: shark
--> $DIR/const_panic_2021.rs:21:20
|
LL | const A_CORE: () = core::panic!("shark");
| ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: shark
| ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic_2021.rs:24:20
|
LL | const B_CORE: () = core::panic!();
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
| ^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic_2021.rs:27:20
|
LL | const C_CORE: () = core::unreachable!();
| ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code
| ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic_2021.rs:30:20
|
LL | const D_CORE: () = core::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented
| ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic_2021.rs:33:20
|
LL | const E_CORE: () = core::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
error: aborting due to 10 previous errors

View File

@@ -6,13 +6,13 @@
use core::panic::PanicInfo;
const Z: () = panic!("cheese");
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const Y: () = unreachable!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
const X: () = unimplemented!();
//~^ ERROR evaluation of constant value failed
//~^ ERROR evaluation panicked
#[lang = "eh_personality"]
fn eh() {}

View File

@@ -1,20 +1,20 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: cheese
--> $DIR/const_panic_libcore_bin.rs:8:15
|
LL | const Z: () = panic!("cheese");
| ^^^^^^^^^^^^^^^^ evaluation panicked: cheese
| ^^^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic_libcore_bin.rs:11:15
|
LL | const Y: () = unreachable!();
| ^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code
| ^^^^^^^^^^^^^^ evaluation of constant value failed
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic_libcore_bin.rs:14:15
|
LL | const X: () = unimplemented!();
| ^^^^^^^^^^^^^^^^ evaluation panicked: not implemented
| ^^^^^^^^^^^^^^^^ evaluation of constant value failed
|
= note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@@ -17,5 +17,5 @@ const fn c() -> u32 {
}
const X: u32 = c();
//~^ ERROR evaluation of constant value failed
//~| NOTE hey
//~^ NOTE evaluation of constant value failed
//~| ERROR hey

View File

@@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
error[E0080]: evaluation panicked: hey
--> $DIR/const_panic_track_caller.rs:19:16
|
LL | const X: u32 = c();
| ^^^ evaluation panicked: hey
| ^^^ evaluation of constant value failed
|
note: inside `c`
--> $DIR/const_panic_track_caller.rs:15:5

View File

@@ -4,7 +4,5 @@ fn main() {}
const Z: i32 = unsafe { *(&1 as *const i32) };
// bad, will thus error in miri
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR evaluation of constant value failed
//~| NOTE dangling pointer
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed
//~| NOTE dangling pointer
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR dangling pointer
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR dangling pointer

Some files were not shown because too many files have changed in this diff Show More