1
Fork 0

Address review comments

This commit is contained in:
Oliver Scherer 2020-09-07 17:30:38 +02:00
parent 90708c15c4
commit 182ed8544d
29 changed files with 184 additions and 179 deletions

View file

@ -1,4 +1,4 @@
use super::{AllocId, Pointer, RawConst, Scalar}; use super::{AllocId, ConstAlloc, Pointer, Scalar};
use crate::mir::interpret::ConstValue; use crate::mir::interpret::ConstValue;
use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty}; use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty};
@ -27,7 +27,7 @@ CloneTypeFoldableAndLiftImpls! {
ErrorHandled, 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 type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> { pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {

View file

@ -123,7 +123,7 @@ pub use self::error::{
ResourceExhaustionInfo, UndefinedBehaviorInfo, UninitBytesAccess, UnsupportedOpInfo, 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}; pub use self::allocation::{Allocation, AllocationExtra, InitMask, Relocations};

View file

@ -14,7 +14,7 @@ use super::{sign_extend, truncate, AllocId, Allocation, InterpResult, Pointer, P
/// Represents the result of const evaluation via the `eval_to_allocation` query. /// Represents the result of const evaluation via the `eval_to_allocation` query.
#[derive(Clone, HashStable)] #[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` // the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
// (so you can use `AllocMap::unwrap_memory`). // (so you can use `AllocMap::unwrap_memory`).
pub alloc_id: AllocId, pub alloc_id: AllocId,

View file

@ -713,7 +713,7 @@ rustc_queries! {
query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
-> EvalToAllocationRawResult<'tcx> { -> EvalToAllocationRawResult<'tcx> {
desc { |tcx| desc { |tcx|
"const-evaluating `{}`", "const-evaluating + checking `{}`",
key.value.display(tcx) key.value.display(tcx)
} }
} }
@ -727,7 +727,7 @@ rustc_queries! {
query eval_to_const_value(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) query eval_to_const_value(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
-> EvalToConstValueResult<'tcx> { -> EvalToConstValueResult<'tcx> {
desc { |tcx| desc { |tcx|
"const-evaluating + checking `{}`", "simplifying constant for the type system `{}`",
key.value.display(tcx) key.value.display(tcx)
} }
cache_on_disk_if(_, opt_result) { cache_on_disk_if(_, opt_result) {

View file

@ -2,7 +2,7 @@ use super::{CompileTimeEvalContext, CompileTimeInterpreter, ConstEvalErr, Memory
use crate::interpret::eval_nullary_intrinsic; use crate::interpret::eval_nullary_intrinsic;
use crate::interpret::{ use crate::interpret::{
intern_const_alloc_recursive, Allocation, ConstValue, GlobalId, Immediate, InternKind, 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, ScalarMaybeUninit, StackPopCleanup,
}; };
@ -184,9 +184,9 @@ pub(super) fn op_to_const<'tcx>(
} }
} }
fn turn_into_const<'tcx>( fn turn_into_const_value<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
constant: RawConst<'tcx>, constant: ConstAlloc<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> ConstValue<'tcx> { ) -> ConstValue<'tcx> {
let cid = key.value; let cid = key.value;
@ -237,7 +237,7 @@ pub fn eval_to_const_value_provider<'tcx>(
}); });
} }
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>( pub fn eval_to_allocation_raw_provider<'tcx>(
@ -402,7 +402,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
)) ))
} else { } else {
// Convert to raw constant // 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 })
} }
} }
} }

View file

@ -469,7 +469,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
// Notice that every static has two `AllocId` that will resolve to the same // 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, // 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 // 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. // 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 // 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! // ID would "sidestep" the checks that make sure consts do not point to statics!

View file

@ -13,9 +13,9 @@ use rustc_target::abi::{Abi, Align, FieldsShape, TagEncoding};
use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants}; use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants};
use super::{ use super::{
mir_assign_valid_types, truncate, AllocId, AllocMap, Allocation, AllocationExtra, ImmTy, mir_assign_valid_types, truncate, AllocId, AllocMap, Allocation, AllocationExtra, ConstAlloc,
Immediate, InterpCx, InterpResult, LocalValue, Machine, MemoryKind, OpTy, Operand, Pointer, ImmTy, Immediate, InterpCx, InterpResult, LocalValue, Machine, MemoryKind, OpTy, Operand,
PointerArithmetic, RawConst, Scalar, ScalarMaybeUninit, Pointer, PointerArithmetic, Scalar, ScalarMaybeUninit,
}; };
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
@ -1122,7 +1122,7 @@ where
pub fn raw_const_to_mplace( pub fn raw_const_to_mplace(
&self, &self,
raw: RawConst<'tcx>, raw: ConstAlloc<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
// This must be an allocation in `tcx` // This must be an allocation in `tcx`
let _ = self.tcx.global_alloc(raw.alloc_id); let _ = self.tcx.global_alloc(raw.alloc_id);

View file

@ -426,27 +426,27 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
if let Some(GlobalAlloc::Static(did)) = alloc_kind { if let Some(GlobalAlloc::Static(did)) = alloc_kind {
assert!(!self.ecx.tcx.is_thread_local_static(did)); assert!(!self.ecx.tcx.is_thread_local_static(did));
assert!(self.ecx.tcx.is_static(did)); assert!(self.ecx.tcx.is_static(did));
// See const_eval::machine::MemoryExtra::can_access_statics for why if self.may_ref_to_static {
// this check is so important. // We skip checking other statics. These statics must be sound by
// This check is reachable when the const just referenced the static, // themselves, and the only way to get broken statics here is by using
// but never read it (so we never entered `before_access_global`). // unsafe code.
// We also need to do it here instead of going on to avoid running // The reasons we don't check other statics is twofold. For one, in all
// into the `before_access_global` check during validation. // sound cases, the static was already validated on its own, and second, we
if !self.may_ref_to_static { // trigger cycle errors if we try to compute the value of the other static
throw_validation_failure!(self.path, // and that static refers back to us.
{ "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, // We might miss const-invalid data,
// but things are still sound otherwise (in particular re: consts // but things are still sound otherwise (in particular re: consts
// referring to statics). // referring to statics).
return Ok(()); 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 }
);
}
} }
} }
// Proceed recursively even for ZST, no reason to skip them! // Proceed recursively even for ZST, no reason to skip them!

View file

@ -1,6 +1,11 @@
error[E0391]: cycle detected when normalizing `<() as Tr>::A` 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 simplifying constant for the type system `Tr::A`...
--> $DIR/defaults-cyclic-fail.rs:6:5 --> $DIR/defaults-cyclic-fail.rs:6:5
| |
LL | const A: u8 = Self::B; LL | const A: u8 = Self::B;
@ -8,15 +13,15 @@ LL | const A: u8 = Self::B;
note: ...which requires const-evaluating + checking `Tr::A`... note: ...which requires const-evaluating + checking `Tr::A`...
--> $DIR/defaults-cyclic-fail.rs:6:5 --> $DIR/defaults-cyclic-fail.rs:6:5
| |
LL | const A: u8 = Self::B;
| ^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `Tr::A`...
--> $DIR/defaults-cyclic-fail.rs:6:5
|
LL | const A: u8 = Self::B; LL | const A: u8 = Self::B;
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<() as Tr>::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 simplifying constant for the type system `Tr::B`...
--> $DIR/defaults-cyclic-fail.rs:8:5 --> $DIR/defaults-cyclic-fail.rs:8:5
| |
LL | const B: u8 = Self::A; LL | const B: u8 = Self::A;
@ -24,15 +29,10 @@ LL | const B: u8 = Self::A;
note: ...which requires const-evaluating + checking `Tr::B`... note: ...which requires const-evaluating + checking `Tr::B`...
--> $DIR/defaults-cyclic-fail.rs:8:5 --> $DIR/defaults-cyclic-fail.rs:8:5
| |
LL | const B: u8 = Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `Tr::B`...
--> $DIR/defaults-cyclic-fail.rs:8:5
|
LL | const B: u8 = Self::A; LL | const B: u8 = Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires normalizing `<() as Tr>::A`, completing the cycle = 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 --> $DIR/defaults-cyclic-fail.rs:14:1
| |
LL | fn main() { LL | fn main() {

View file

@ -1,21 +1,26 @@
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 --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
| |
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; LL | const IMPL_REF_BAR: u32 = GlobalImplRef::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 + checking `IMPL_REF_BAR`... note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 --> $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`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; 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 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 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 --> $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;
@ -25,18 +30,13 @@ note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-a
| |
LL | const BAR: u32 = IMPL_REF_BAR; 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`...
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
LL | const BAR: u32 = IMPL_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires optimizing MIR for `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`... note: ...which requires optimizing MIR for `<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 --> $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 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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,21 +1,26 @@
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 --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
| |
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::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 + checking `DEFAULT_REF_BAR`... note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 --> $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`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<GlobalDefaultRef as FooDefault>::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 simplifying constant for the type system `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 --> $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;
@ -25,18 +30,13 @@ note: ...which requires const-evaluating + checking `FooDefault::BAR`...
| |
LL | const BAR: u32 = DEFAULT_REF_BAR; LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
LL | const BAR: u32 = DEFAULT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires optimizing MIR for `FooDefault::BAR`... note: ...which requires optimizing MIR for `FooDefault::BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 --> $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 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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,21 +1,26 @@
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 --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
| |
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::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 + checking `TRAIT_REF_BAR`... note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 --> $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`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `<GlobalTraitRef as Foo>::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 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 --> $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;
@ -25,18 +30,13 @@ note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-a
| |
LL | const BAR: u32 = TRAIT_REF_BAR; 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`...
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
LL | const BAR: u32 = TRAIT_REF_BAR;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires optimizing MIR for `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`... note: ...which requires optimizing MIR for `<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 --> $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 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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,9 +9,9 @@ LL | let x: &'static i32 = &(1 / 0);
= note: `#[deny(const_err)]` on by default = note: `#[deny(const_err)]` on by default
query stack during panic: query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating `main::promoted[1]` #0 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[1]`
#1 [eval_to_const_value] 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] const-evaluating + checking `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]` #3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
#4 [optimized_mir] optimizing MIR for `main` #4 [optimized_mir] optimizing MIR for `main`
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items #5 [collect_and_partition_mono_items] collect_and_partition_mono_items

View file

@ -1,32 +1,32 @@
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 --> $DIR/const-size_of-cycle.rs:4:17
| |
LL | bytes: [u8; std::mem::size_of::<Foo>()] LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
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 + checking `Foo::bytes::{{constant}}#0`... note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}#0`...
--> $DIR/const-size_of-cycle.rs:4:17 --> $DIR/const-size_of-cycle.rs:4:17
| |
LL | bytes: [u8; std::mem::size_of::<Foo>()] LL | bytes: [u8; std::mem::size_of::<Foo>()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `Foo::bytes::{{constant}}#0`... note: ...which requires const-evaluating + checking `std::mem::size_of`...
--> $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`...
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
| |
LL | pub const fn size_of<T>() -> usize { 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 --> $SRC_DIR/core/src/intrinsics.rs:LL:COL
| |
LL | pub fn size_of<T>() -> usize; LL | pub fn size_of<T>() -> usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing layout of `Foo`... = note: ...which requires computing layout of `Foo`...
= note: ...which requires normalizing `[u8; _]`... = 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 note: cycle used when checking that `Foo` is well-formed
--> $DIR/const-size_of-cycle.rs:3:1 --> $DIR/const-size_of-cycle.rs:3:1
| |

View file

@ -1,15 +1,15 @@
error[E0391]: cycle detected when const-evaluating `FOO` error[E0391]: cycle detected when const-evaluating + checking `FOO`
--> $DIR/recursive-zst-static.rs:10:1 --> $DIR/recursive-zst-static.rs:10:1
| |
LL | static FOO: () = FOO; LL | static FOO: () = FOO;
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
| |
note: ...which requires const-evaluating `FOO`... note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/recursive-zst-static.rs:10:1 --> $DIR/recursive-zst-static.rs:10:1
| |
LL | static FOO: () = FOO; 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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@
// can depend on this fact and will thus do unsound things when it is violated. // 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. // 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() { fn main() {
FOO FOO

View file

@ -1,15 +1,15 @@
error[E0391]: cycle detected when const-evaluating `FOO` error[E0391]: cycle detected when const-evaluating + checking `FOO`
--> $DIR/recursive-zst-static.rs:10:1 --> $DIR/recursive-zst-static.rs:10:1
| |
LL | static FOO: () = FOO; LL | static FOO: () = FOO;
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
| |
note: ...which requires const-evaluating `FOO`... note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/recursive-zst-static.rs:10:1 --> $DIR/recursive-zst-static.rs:10:1
| |
LL | static FOO: () = FOO; 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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,7 +1,12 @@
//https://github.com/rust-lang/rust/issues/31364 //https://github.com/rust-lang/rust/issues/31364
const fn a() -> usize { b() } //~ ERROR cycle detected when const-evaluating `a` [E0391] const fn a() -> usize {
const fn b() -> usize { a() } //~^ ERROR cycle detected when const-evaluating + checking `a` [E0391]
b()
}
const fn b() -> usize {
a()
}
const ARR: [i32; a()] = [5; 6]; const ARR: [i32; a()] = [5; 6];
fn main() {} fn main() {}

View file

@ -1,17 +1,17 @@
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 --> $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`... note: ...which requires const-evaluating + checking `b`...
--> $DIR/infinite-recursion-const-fn.rs:4:1 --> $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: ...which again requires const-evaluating + checking `a`, completing the cycle
note: cycle used when const-evaluating `ARR::{{constant}}#0` note: cycle used when const-evaluating + checking `ARR::{{constant}}#0`
--> $DIR/infinite-recursion-const-fn.rs:5:18 --> $DIR/infinite-recursion-const-fn.rs:10:18
| |
LL | const ARR: [i32; a()] = [5; 6]; LL | const ARR: [i32; a()] = [5; 6];
| ^^^ | ^^^

View file

@ -1,6 +1,11 @@
error[E0391]: cycle detected when normalizing `FOO` 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 simplifying constant for the type system `FOO`...
--> $DIR/issue-17252.rs:1:1 --> $DIR/issue-17252.rs:1:1
| |
LL | const FOO: usize = FOO; LL | const FOO: usize = FOO;
@ -8,15 +13,10 @@ LL | const FOO: usize = FOO;
note: ...which requires const-evaluating + checking `FOO`... note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/issue-17252.rs:1:1 --> $DIR/issue-17252.rs:1:1
| |
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `FOO`...
--> $DIR/issue-17252.rs:1:1
|
LL | const FOO: usize = FOO; LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires normalizing `FOO`, completing the cycle = 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 --> $DIR/issue-17252.rs:4:18
| |
LL | let _x: [u8; FOO]; // caused stack overflow prior to fix LL | let _x: [u8; FOO]; // caused stack overflow prior to fix

View file

@ -1,21 +1,21 @@
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 --> $DIR/issue-23302-1.rs:4:9
| |
LL | A = X::A as isize, LL | A = X::A as isize,
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
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 + checking `X::A::{{constant}}#0`... note: ...which requires const-evaluating + checking `X::A::{{constant}}#0`...
--> $DIR/issue-23302-1.rs:4:9 --> $DIR/issue-23302-1.rs:4:9
| |
LL | A = X::A as isize,
| ^^^^^^^^^^^^^
note: ...which requires const-evaluating `X::A::{{constant}}#0`...
--> $DIR/issue-23302-1.rs:4:9
|
LL | A = X::A as isize, LL | A = X::A as isize,
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
= note: ...which requires normalizing `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 note: cycle used when collecting item types in top-level module
--> $DIR/issue-23302-1.rs:3:1 --> $DIR/issue-23302-1.rs:3:1
| |

View file

@ -1,21 +1,21 @@
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 --> $DIR/issue-23302-2.rs:4:9
| |
LL | A = Y::B as isize, LL | A = Y::B as isize,
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
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 + checking `Y::A::{{constant}}#0`... note: ...which requires const-evaluating + checking `Y::A::{{constant}}#0`...
--> $DIR/issue-23302-2.rs:4:9 --> $DIR/issue-23302-2.rs:4:9
| |
LL | A = Y::B as isize,
| ^^^^^^^^^^^^^
note: ...which requires const-evaluating `Y::A::{{constant}}#0`...
--> $DIR/issue-23302-2.rs:4:9
|
LL | A = Y::B as isize, LL | A = Y::B as isize,
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
= note: ...which requires normalizing `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 note: cycle used when collecting item types in top-level module
--> $DIR/issue-23302-2.rs:3:1 --> $DIR/issue-23302-2.rs:3:1
| |

View file

@ -1,21 +1,26 @@
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 --> $DIR/issue-23302-3.rs:1:1
| |
LL | const A: i32 = B; LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
| |
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 + checking `A`... note: ...which requires const-evaluating + checking `A`...
--> $DIR/issue-23302-3.rs:1:1 --> $DIR/issue-23302-3.rs:1:1
| |
LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `A`...
--> $DIR/issue-23302-3.rs:1:1
|
LL | const A: i32 = B; LL | const A: i32 = B;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `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 simplifying constant for the type system `B`...
--> $DIR/issue-23302-3.rs:3:1 --> $DIR/issue-23302-3.rs:3:1
| |
LL | const B: i32 = A; LL | const B: i32 = A;
@ -23,15 +28,10 @@ LL | const B: i32 = A;
note: ...which requires const-evaluating + checking `B`... note: ...which requires const-evaluating + checking `B`...
--> $DIR/issue-23302-3.rs:3:1 --> $DIR/issue-23302-3.rs:3:1
| |
LL | const B: i32 = A;
| ^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `B`...
--> $DIR/issue-23302-3.rs:3:1
|
LL | const B: i32 = A; LL | const B: i32 = A;
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -1,21 +1,26 @@
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 --> $DIR/issue-36163.rs:4:9
| |
LL | B = A, LL | B = A,
| ^ | ^
| |
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 + checking `Foo::B::{{constant}}#0`... note: ...which requires const-evaluating + checking `Foo::B::{{constant}}#0`...
--> $DIR/issue-36163.rs:4:9 --> $DIR/issue-36163.rs:4:9
| |
LL | B = A,
| ^
note: ...which requires const-evaluating `Foo::B::{{constant}}#0`...
--> $DIR/issue-36163.rs:4:9
|
LL | B = A, LL | B = A,
| ^ | ^
= note: ...which requires normalizing `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 simplifying constant for the type system `A`...
--> $DIR/issue-36163.rs:1:1 --> $DIR/issue-36163.rs:1:1
| |
LL | const A: isize = Foo::B as isize; LL | const A: isize = Foo::B as isize;
@ -23,15 +28,10 @@ LL | const A: isize = Foo::B as isize;
note: ...which requires const-evaluating + checking `A`... note: ...which requires const-evaluating + checking `A`...
--> $DIR/issue-36163.rs:1:1 --> $DIR/issue-36163.rs:1:1
| |
LL | const A: isize = Foo::B as isize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating `A`...
--> $DIR/issue-36163.rs:1:1
|
LL | const A: isize = Foo::B as isize; LL | const A: isize = Foo::B as isize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires normalizing `A`... = 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 note: cycle used when collecting item types in top-level module
--> $DIR/issue-36163.rs:1:1 --> $DIR/issue-36163.rs:1:1
| |

View file

@ -1,4 +1,4 @@
pub static FOO: u32 = FOO; pub static FOO: u32 = FOO;
//~^ ERROR cycle detected when const-evaluating `FOO` //~^ ERROR cycle detected when const-evaluating + checking `FOO`
fn main() {} fn main() {}

View file

@ -1,15 +1,15 @@
error[E0391]: cycle detected when const-evaluating `FOO` error[E0391]: cycle detected when const-evaluating + checking `FOO`
--> $DIR/recursive-static-definition.rs:1:1 --> $DIR/recursive-static-definition.rs:1:1
| |
LL | pub static FOO: u32 = FOO; 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 --> $DIR/recursive-static-definition.rs:1:1
| |
LL | pub static FOO: u32 = FOO; 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 = note: cycle used when running analysis passes on this crate
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,7 +2,7 @@
enum Alpha { enum Alpha {
V1 = 41, V1 = 41,
V2 = Self::V1 as u8 + 1, // OK; See #50072. V2 = Self::V1 as u8 + 1, // OK; See #50072.
V3 = Self::V1 {} as u8 + 2, //~ ERROR cycle detected when const-evaluating V3 = Self::V1 {} as u8 + 2, //~ ERROR cycle detected when simplifying constant
} }
fn main() {} fn main() {}

View file

@ -1,21 +1,21 @@
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 --> $DIR/self-in-enum-definition.rs:5:10
| |
LL | V3 = Self::V1 {} as u8 + 2, LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^ | ^^^^^^^^
| |
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 + checking `Alpha::V3::{{constant}}#0`... note: ...which requires const-evaluating + checking `Alpha::V3::{{constant}}#0`...
--> $DIR/self-in-enum-definition.rs:5:10 --> $DIR/self-in-enum-definition.rs:5:10
| |
LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^
note: ...which requires const-evaluating `Alpha::V3::{{constant}}#0`...
--> $DIR/self-in-enum-definition.rs:5:10
|
LL | V3 = Self::V1 {} as u8 + 2, LL | V3 = Self::V1 {} as u8 + 2,
| ^^^^^^^^ | ^^^^^^^^
= note: ...which requires computing layout of `Alpha`... = 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 note: cycle used when collecting item types in top-level module
--> $DIR/self-in-enum-definition.rs:1:1 --> $DIR/self-in-enum-definition.rs:1:1
| |

View file

@ -4,18 +4,18 @@ error[E0080]: could not evaluate static initializer
LL | pub static mut B: () = unsafe { A = 1; }; LL | pub static mut B: () = unsafe { A = 1; };
| ^^^^^ modifying a static's initial value from another static's initializer | ^^^^^ 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 --> $DIR/write-to-static-mut-in-static.rs:5:1
| |
LL | pub static mut C: u32 = unsafe { C = 1; 0 }; 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 --> $DIR/write-to-static-mut-in-static.rs:5:1
| |
LL | pub static mut C: u32 = unsafe { C = 1; 0 }; 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 = note: cycle used when running analysis passes on this crate
error: aborting due to 2 previous errors error: aborting due to 2 previous errors