-use super::{AllocId, Pointer, RawConst, Scalar};
+use super::{AllocId, ConstAlloc, Pointer, Scalar};
use crate::mir::interpret::ConstValue;
use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty};
ErrorHandled,
}
-pub type EvalToAllocationRawResult<'tcx> = Result<RawConst<'tcx>, ErrorHandled>;
+pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled>;
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {
ResourceExhaustionInfo, UndefinedBehaviorInfo, UninitBytesAccess, UnsupportedOpInfo,
};
-pub use self::value::{get_slice_bytes, ConstValue, RawConst, Scalar, ScalarMaybeUninit};
+pub use self::value::{get_slice_bytes, ConstAlloc, ConstValue, Scalar, ScalarMaybeUninit};
pub use self::allocation::{Allocation, AllocationExtra, InitMask, Relocations};
/// Represents the result of const evaluation via the `eval_to_allocation` query.
#[derive(Clone, HashStable)]
-pub struct RawConst<'tcx> {
+pub struct ConstAlloc<'tcx> {
// the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
// (so you can use `AllocMap::unwrap_memory`).
pub alloc_id: AllocId,
query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
-> EvalToAllocationRawResult<'tcx> {
desc { |tcx|
- "const-evaluating `{}`",
+ "const-evaluating + checking `{}`",
key.value.display(tcx)
}
}
query eval_to_const_value(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
-> EvalToConstValueResult<'tcx> {
desc { |tcx|
- "const-evaluating + checking `{}`",
+ "simplifying constant for the type system `{}`",
key.value.display(tcx)
}
cache_on_disk_if(_, opt_result) {
use crate::interpret::eval_nullary_intrinsic;
use crate::interpret::{
intern_const_alloc_recursive, Allocation, ConstValue, GlobalId, Immediate, InternKind,
- InterpCx, InterpResult, MPlaceTy, MemoryKind, OpTy, RawConst, RefTracking, Scalar,
+ InterpCx, InterpResult, MPlaceTy, MemoryKind, OpTy, ConstAlloc, RefTracking, Scalar,
ScalarMaybeUninit, StackPopCleanup,
};
}
}
-fn turn_into_const<'tcx>(
+fn turn_into_const_value<'tcx>(
tcx: TyCtxt<'tcx>,
- constant: RawConst<'tcx>,
+ constant: ConstAlloc<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> ConstValue<'tcx> {
let cid = key.value;
});
}
- tcx.eval_to_allocation_raw(key).map(|val| turn_into_const(tcx, val, key))
+ tcx.eval_to_allocation_raw(key).map(|val| turn_into_const_value(tcx, val, key))
}
pub fn eval_to_allocation_raw_provider<'tcx>(
))
} else {
// Convert to raw constant
- Ok(RawConst { alloc_id: mplace.ptr.assert_ptr().alloc_id, ty: mplace.layout.ty })
+ Ok(ConstAlloc { alloc_id: mplace.ptr.assert_ptr().alloc_id, ty: mplace.layout.ty })
}
}
}
// Notice that every static has two `AllocId` that will resolve to the same
// thing here: one maps to `GlobalAlloc::Static`, this is the "lazy" ID,
// and the other one is maps to `GlobalAlloc::Memory`, this is returned by
- // `const_eval` and it is the "resolved" ID.
+ // `eval_static_initializer` and it is the "resolved" ID.
// The resolved ID is never used by the interpreted program, it is hidden.
// This is relied upon for soundness of const-patterns; a pointer to the resolved
// ID would "sidestep" the checks that make sure consts do not point to statics!
use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants};
use super::{
- mir_assign_valid_types, truncate, AllocId, AllocMap, Allocation, AllocationExtra, ImmTy,
- Immediate, InterpCx, InterpResult, LocalValue, Machine, MemoryKind, OpTy, Operand, Pointer,
- PointerArithmetic, RawConst, Scalar, ScalarMaybeUninit,
+ mir_assign_valid_types, truncate, AllocId, AllocMap, Allocation, AllocationExtra, ConstAlloc,
+ ImmTy, Immediate, InterpCx, InterpResult, LocalValue, Machine, MemoryKind, OpTy, Operand,
+ Pointer, PointerArithmetic, Scalar, ScalarMaybeUninit,
};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
pub fn raw_const_to_mplace(
&self,
- raw: RawConst<'tcx>,
+ raw: ConstAlloc<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
// This must be an allocation in `tcx`
let _ = self.tcx.global_alloc(raw.alloc_id);
if let Some(GlobalAlloc::Static(did)) = alloc_kind {
assert!(!self.ecx.tcx.is_thread_local_static(did));
assert!(self.ecx.tcx.is_static(did));
- // See const_eval::machine::MemoryExtra::can_access_statics for why
- // this check is so important.
- // This check is reachable when the const just referenced the static,
- // but never read it (so we never entered `before_access_global`).
- // We also need to do it here instead of going on to avoid running
- // into the `before_access_global` check during validation.
- if !self.may_ref_to_static {
+ if self.may_ref_to_static {
+ // We skip checking other statics. These statics must be sound by
+ // themselves, and the only way to get broken statics here is by using
+ // unsafe code.
+ // The reasons we don't check other statics is twofold. For one, in all
+ // sound cases, the static was already validated on its own, and second, we
+ // trigger cycle errors if we try to compute the value of the other static
+ // and that static refers back to us.
+ // We might miss const-invalid data,
+ // but things are still sound otherwise (in particular re: consts
+ // referring to statics).
+ return Ok(());
+ } else {
+ // See const_eval::machine::MemoryExtra::can_access_statics for why
+ // this check is so important.
+ // This check is reachable when the const just referenced the static,
+ // but never read it (so we never entered `before_access_global`).
throw_validation_failure!(self.path,
{ "a {} pointing to a static variable", kind }
);
}
- // We skip checking other statics. These statics must be sound by themselves,
- // and the only way to get broken statics here is by using unsafe code.
- // The reasons we don't check other statics is twofold. For one, in all sound
- // cases, the static was already validated on its own, and second, we trigger
- // cycle errors if we try to compute the value of the other static and that
- // static refers back to us.
- // We might miss const-invalid data,
- // but things are still sound otherwise (in particular re: consts
- // referring to statics).
- return Ok(());
}
}
// Proceed recursively even for ZST, no reason to skip them!
error[E0391]: cycle detected when normalizing `<() as Tr>::A`
|
-note: ...which requires const-evaluating + checking `Tr::A`...
+note: ...which requires simplifying constant for the type system `Tr::A`...
--> $DIR/defaults-cyclic-fail.rs:6:5
|
LL | const A: u8 = Self::B;
| ^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `Tr::A`...
+note: ...which requires simplifying constant for the type system `Tr::A`...
--> $DIR/defaults-cyclic-fail.rs:6:5
|
LL | const A: u8 = Self::B;
| ^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `Tr::A`...
+note: ...which requires const-evaluating + checking `Tr::A`...
--> $DIR/defaults-cyclic-fail.rs:6:5
|
LL | const A: u8 = Self::B;
| ^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<() as Tr>::B`...
-note: ...which requires const-evaluating + checking `Tr::B`...
+note: ...which requires simplifying constant for the type system `Tr::B`...
--> $DIR/defaults-cyclic-fail.rs:8:5
|
LL | const B: u8 = Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `Tr::B`...
+note: ...which requires simplifying constant for the type system `Tr::B`...
--> $DIR/defaults-cyclic-fail.rs:8:5
|
LL | const B: u8 = Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `Tr::B`...
+note: ...which requires const-evaluating + checking `Tr::B`...
--> $DIR/defaults-cyclic-fail.rs:8:5
|
LL | const B: u8 = Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires normalizing `<() as Tr>::A`, completing the cycle
-note: cycle used when const-evaluating `main::promoted[2]`
+note: cycle used when const-evaluating + checking `main::promoted[2]`
--> $DIR/defaults-cyclic-fail.rs:14:1
|
LL | fn main() {
-error[E0391]: cycle detected when const-evaluating + checking `IMPL_REF_BAR`
+error[E0391]: cycle detected when simplifying constant for the type system `IMPL_REF_BAR`
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
+note: ...which requires simplifying constant for the type system `IMPL_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `IMPL_REF_BAR`...
+note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
-note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
+note: ...which requires simplifying constant for the type system `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
LL | const BAR: u32 = IMPL_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
+note: ...which requires simplifying constant for the type system `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
LL | const BAR: u32 = IMPL_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
+note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
LL | const BAR: u32 = IMPL_REF_BAR;
LL | const BAR: u32 = IMPL_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `IMPL_REF_BAR`...
- = note: ...which again requires const-evaluating + checking `IMPL_REF_BAR`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `IMPL_REF_BAR`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
-error[E0391]: cycle detected when const-evaluating + checking `DEFAULT_REF_BAR`
+error[E0391]: cycle detected when simplifying constant for the type system `DEFAULT_REF_BAR`
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
+note: ...which requires simplifying constant for the type system `DEFAULT_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `DEFAULT_REF_BAR`...
+note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<GlobalDefaultRef as FooDefault>::BAR`...
-note: ...which requires const-evaluating + checking `FooDefault::BAR`...
+note: ...which requires simplifying constant for the type system `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `FooDefault::BAR`...
+note: ...which requires simplifying constant for the type system `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `FooDefault::BAR`...
+note: ...which requires const-evaluating + checking `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `DEFAULT_REF_BAR`...
- = note: ...which again requires const-evaluating + checking `DEFAULT_REF_BAR`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `DEFAULT_REF_BAR`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
-error[E0391]: cycle detected when const-evaluating + checking `TRAIT_REF_BAR`
+error[E0391]: cycle detected when simplifying constant for the type system `TRAIT_REF_BAR`
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
+note: ...which requires simplifying constant for the type system `TRAIT_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `TRAIT_REF_BAR`...
+note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<GlobalTraitRef as Foo>::BAR`...
-note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`...
+note: ...which requires simplifying constant for the type system `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`...
+note: ...which requires simplifying constant for the type system `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`...
+note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
LL | const BAR: u32 = TRAIT_REF_BAR;
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `TRAIT_REF_BAR`...
- = note: ...which again requires const-evaluating + checking `TRAIT_REF_BAR`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `TRAIT_REF_BAR`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
= note: `#[deny(const_err)]` on by default
query stack during panic:
-#0 [eval_to_allocation_raw] const-evaluating `main::promoted[1]`
-#1 [eval_to_const_value] const-evaluating + checking `main::promoted[1]`
-#2 [eval_to_const_value] const-evaluating + checking `main::promoted[1]`
+#0 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[1]`
+#1 [eval_to_const_value] simplifying constant for the type system `main::promoted[1]`
+#2 [eval_to_const_value] simplifying constant for the type system `main::promoted[1]`
#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
#4 [optimized_mir] optimizing MIR for `main`
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
-error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}#0`
+error[E0391]: cycle detected when simplifying constant for the type system `Foo::bytes::{{constant}}#0`
--> $DIR/const-size_of-cycle.rs:4:17
|
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}#0`...
+note: ...which requires simplifying constant for the type system `Foo::bytes::{{constant}}#0`...
--> $DIR/const-size_of-cycle.rs:4:17
|
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `Foo::bytes::{{constant}}#0`...
+note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}#0`...
--> $DIR/const-size_of-cycle.rs:4:17
|
LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `std::mem::size_of`...
+note: ...which requires const-evaluating + checking `std::mem::size_of`...
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
LL | pub const fn size_of<T>() -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `std::intrinsics::size_of`...
+note: ...which requires simplifying constant for the type system `std::intrinsics::size_of`...
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
|
LL | pub fn size_of<T>() -> usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `Foo`...
= note: ...which requires normalizing `[u8; _]`...
- = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}#0`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `Foo::bytes::{{constant}}#0`, completing the cycle
note: cycle used when checking that `Foo` is well-formed
--> $DIR/const-size_of-cycle.rs:3:1
|
-error[E0391]: cycle detected when const-evaluating `FOO`
+error[E0391]: cycle detected when const-evaluating + checking `FOO`
--> $DIR/recursive-zst-static.rs:10:1
|
LL | static FOO: () = FOO;
| ^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating `FOO`...
+note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/recursive-zst-static.rs:10:1
|
LL | static FOO: () = FOO;
| ^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires const-evaluating `FOO`, completing the cycle
+ = note: ...which again requires const-evaluating + checking `FOO`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
// can depend on this fact and will thus do unsound things when it is violated.
// See https://github.com/rust-lang/rust/issues/71078 for more details.
-static FOO: () = FOO; //~ cycle detected when const-evaluating `FOO`
+static FOO: () = FOO; //~ cycle detected when const-evaluating + checking `FOO`
fn main() {
FOO
-error[E0391]: cycle detected when const-evaluating `FOO`
+error[E0391]: cycle detected when const-evaluating + checking `FOO`
--> $DIR/recursive-zst-static.rs:10:1
|
LL | static FOO: () = FOO;
| ^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating `FOO`...
+note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/recursive-zst-static.rs:10:1
|
LL | static FOO: () = FOO;
| ^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires const-evaluating `FOO`, completing the cycle
+ = note: ...which again requires const-evaluating + checking `FOO`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
//https://github.com/rust-lang/rust/issues/31364
-const fn a() -> usize { b() } //~ ERROR cycle detected when const-evaluating `a` [E0391]
-const fn b() -> usize { a() }
+const fn a() -> usize {
+ //~^ ERROR cycle detected when const-evaluating + checking `a` [E0391]
+ b()
+}
+const fn b() -> usize {
+ a()
+}
const ARR: [i32; a()] = [5; 6];
-fn main(){}
+fn main() {}
-error[E0391]: cycle detected when const-evaluating `a`
+error[E0391]: cycle detected when const-evaluating + checking `a`
--> $DIR/infinite-recursion-const-fn.rs:3:1
|
-LL | const fn a() -> usize { b() }
+LL | const fn a() -> usize {
| ^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating `b`...
- --> $DIR/infinite-recursion-const-fn.rs:4:1
+note: ...which requires const-evaluating + checking `b`...
+ --> $DIR/infinite-recursion-const-fn.rs:7:1
|
-LL | const fn b() -> usize { a() }
+LL | const fn b() -> usize {
| ^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires const-evaluating `a`, completing the cycle
-note: cycle used when const-evaluating `ARR::{{constant}}#0`
- --> $DIR/infinite-recursion-const-fn.rs:5:18
+ = note: ...which again requires const-evaluating + checking `a`, completing the cycle
+note: cycle used when const-evaluating + checking `ARR::{{constant}}#0`
+ --> $DIR/infinite-recursion-const-fn.rs:10:18
|
LL | const ARR: [i32; a()] = [5; 6];
| ^^^
error[E0391]: cycle detected when normalizing `FOO`
|
-note: ...which requires const-evaluating + checking `FOO`...
+note: ...which requires simplifying constant for the type system `FOO`...
--> $DIR/issue-17252.rs:1:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `FOO`...
+note: ...which requires simplifying constant for the type system `FOO`...
--> $DIR/issue-17252.rs:1:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `FOO`...
+note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/issue-17252.rs:1:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires normalizing `FOO`, completing the cycle
-note: cycle used when const-evaluating `main::{{constant}}#0`
+note: cycle used when const-evaluating + checking `main::{{constant}}#0`
--> $DIR/issue-17252.rs:4:18
|
LL | let _x: [u8; FOO]; // caused stack overflow prior to fix
-error[E0391]: cycle detected when const-evaluating + checking `X::A::{{constant}}#0`
+error[E0391]: cycle detected when simplifying constant for the type system `X::A::{{constant}}#0`
--> $DIR/issue-23302-1.rs:4:9
|
LL | A = X::A as isize,
| ^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `X::A::{{constant}}#0`...
+note: ...which requires simplifying constant for the type system `X::A::{{constant}}#0`...
--> $DIR/issue-23302-1.rs:4:9
|
LL | A = X::A as isize,
| ^^^^^^^^^^^^^
-note: ...which requires const-evaluating `X::A::{{constant}}#0`...
+note: ...which requires const-evaluating + checking `X::A::{{constant}}#0`...
--> $DIR/issue-23302-1.rs:4:9
|
LL | A = X::A as isize,
| ^^^^^^^^^^^^^
= note: ...which requires normalizing `X::A as isize`...
- = note: ...which again requires const-evaluating + checking `X::A::{{constant}}#0`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `X::A::{{constant}}#0`, completing the cycle
note: cycle used when collecting item types in top-level module
--> $DIR/issue-23302-1.rs:3:1
|
-error[E0391]: cycle detected when const-evaluating + checking `Y::A::{{constant}}#0`
+error[E0391]: cycle detected when simplifying constant for the type system `Y::A::{{constant}}#0`
--> $DIR/issue-23302-2.rs:4:9
|
LL | A = Y::B as isize,
| ^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `Y::A::{{constant}}#0`...
+note: ...which requires simplifying constant for the type system `Y::A::{{constant}}#0`...
--> $DIR/issue-23302-2.rs:4:9
|
LL | A = Y::B as isize,
| ^^^^^^^^^^^^^
-note: ...which requires const-evaluating `Y::A::{{constant}}#0`...
+note: ...which requires const-evaluating + checking `Y::A::{{constant}}#0`...
--> $DIR/issue-23302-2.rs:4:9
|
LL | A = Y::B as isize,
| ^^^^^^^^^^^^^
= note: ...which requires normalizing `Y::B as isize`...
- = note: ...which again requires const-evaluating + checking `Y::A::{{constant}}#0`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `Y::A::{{constant}}#0`, completing the cycle
note: cycle used when collecting item types in top-level module
--> $DIR/issue-23302-2.rs:3:1
|
-error[E0391]: cycle detected when const-evaluating + checking `A`
+error[E0391]: cycle detected when simplifying constant for the type system `A`
--> $DIR/issue-23302-3.rs:1:1
|
LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating + checking `A`...
+note: ...which requires simplifying constant for the type system `A`...
--> $DIR/issue-23302-3.rs:1:1
|
LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `A`...
+note: ...which requires const-evaluating + checking `A`...
--> $DIR/issue-23302-3.rs:1:1
|
LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `B`...
-note: ...which requires const-evaluating + checking `B`...
+note: ...which requires simplifying constant for the type system `B`...
--> $DIR/issue-23302-3.rs:3:1
|
LL | const B: i32 = A;
| ^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `B`...
+note: ...which requires simplifying constant for the type system `B`...
--> $DIR/issue-23302-3.rs:3:1
|
LL | const B: i32 = A;
| ^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `B`...
+note: ...which requires const-evaluating + checking `B`...
--> $DIR/issue-23302-3.rs:3:1
|
LL | const B: i32 = A;
| ^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `A`...
- = note: ...which again requires const-evaluating + checking `A`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `A`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
-error[E0391]: cycle detected when const-evaluating + checking `Foo::B::{{constant}}#0`
+error[E0391]: cycle detected when simplifying constant for the type system `Foo::B::{{constant}}#0`
--> $DIR/issue-36163.rs:4:9
|
LL | B = A,
| ^
|
-note: ...which requires const-evaluating + checking `Foo::B::{{constant}}#0`...
+note: ...which requires simplifying constant for the type system `Foo::B::{{constant}}#0`...
--> $DIR/issue-36163.rs:4:9
|
LL | B = A,
| ^
-note: ...which requires const-evaluating `Foo::B::{{constant}}#0`...
+note: ...which requires const-evaluating + checking `Foo::B::{{constant}}#0`...
--> $DIR/issue-36163.rs:4:9
|
LL | B = A,
| ^
= note: ...which requires normalizing `A`...
-note: ...which requires const-evaluating + checking `A`...
+note: ...which requires simplifying constant for the type system `A`...
--> $DIR/issue-36163.rs:1:1
|
LL | const A: isize = Foo::B as isize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating + checking `A`...
+note: ...which requires simplifying constant for the type system `A`...
--> $DIR/issue-36163.rs:1:1
|
LL | const A: isize = Foo::B as isize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires const-evaluating `A`...
+note: ...which requires const-evaluating + checking `A`...
--> $DIR/issue-36163.rs:1:1
|
LL | const A: isize = Foo::B as isize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `A`...
- = note: ...which again requires const-evaluating + checking `Foo::B::{{constant}}#0`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `Foo::B::{{constant}}#0`, completing the cycle
note: cycle used when collecting item types in top-level module
--> $DIR/issue-36163.rs:1:1
|
pub static FOO: u32 = FOO;
-//~^ ERROR cycle detected when const-evaluating `FOO`
+//~^ ERROR cycle detected when const-evaluating + checking `FOO`
fn main() {}
-error[E0391]: cycle detected when const-evaluating `FOO`
+error[E0391]: cycle detected when const-evaluating + checking `FOO`
--> $DIR/recursive-static-definition.rs:1:1
|
LL | pub static FOO: u32 = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating `FOO`...
+note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/recursive-static-definition.rs:1:1
|
LL | pub static FOO: u32 = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires const-evaluating `FOO`, completing the cycle
+ = note: ...which again requires const-evaluating + checking `FOO`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to previous error
#[repr(u8)]
enum Alpha {
V1 = 41,
- V2 = Self::V1 as u8 + 1, // OK; See #50072.
- V3 = Self::V1 {} as u8 + 2, //~ ERROR cycle detected when const-evaluating
+ V2 = Self::V1 as u8 + 1, // OK; See #50072.
+ V3 = Self::V1 {} as u8 + 2, //~ ERROR cycle detected when simplifying constant
}
fn main() {}
-error[E0391]: cycle detected when const-evaluating + checking `Alpha::V3::{{constant}}#0`
+error[E0391]: cycle detected when simplifying constant for the type system `Alpha::V3::{{constant}}#0`
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
|
-note: ...which requires const-evaluating + checking `Alpha::V3::{{constant}}#0`...
+note: ...which requires simplifying constant for the type system `Alpha::V3::{{constant}}#0`...
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
-note: ...which requires const-evaluating `Alpha::V3::{{constant}}#0`...
+note: ...which requires const-evaluating + checking `Alpha::V3::{{constant}}#0`...
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
= note: ...which requires computing layout of `Alpha`...
- = note: ...which again requires const-evaluating + checking `Alpha::V3::{{constant}}#0`, completing the cycle
+ = note: ...which again requires simplifying constant for the type system `Alpha::V3::{{constant}}#0`, completing the cycle
note: cycle used when collecting item types in top-level module
--> $DIR/self-in-enum-definition.rs:1:1
|
LL | / #[repr(u8)]
LL | | enum Alpha {
LL | | V1 = 41,
-LL | | V2 = Self::V1 as u8 + 1, // OK; See #50072.
+LL | | V2 = Self::V1 as u8 + 1, // OK; See #50072.
... |
LL | |
LL | | fn main() {}
LL | pub static mut B: () = unsafe { A = 1; };
| ^^^^^ modifying a static's initial value from another static's initializer
-error[E0391]: cycle detected when const-evaluating `C`
+error[E0391]: cycle detected when const-evaluating + checking `C`
--> $DIR/write-to-static-mut-in-static.rs:5:1
|
LL | pub static mut C: u32 = unsafe { C = 1; 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: ...which requires const-evaluating `C`...
+note: ...which requires const-evaluating + checking `C`...
--> $DIR/write-to-static-mut-in-static.rs:5:1
|
LL | pub static mut C: u32 = unsafe { C = 1; 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: ...which again requires const-evaluating `C`, completing the cycle
+ = note: ...which again requires const-evaluating + checking `C`, completing the cycle
= note: cycle used when running analysis passes on this crate
error: aborting due to 2 previous errors