-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedIssue: A query cycle occurred while none was expectedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
const fn f() -> impl Eq { g() }
const fn g() {}
// OK: const fn f() -> impl Eq { g(); }
// OK: const fn f() -> impl Eq {}
// OK: const fn f() -> impl Eq { (g(),).0 }
I expected to see this happen: Successful compilation
Instead, this happened:
error[E0391]: cycle detected when computing type of `f::{opaque#0}`
--> src/lib.rs:1:17
|
1 | const fn f() -> impl Eq { g() }
| ^^^^^^^
|
note: ...which requires borrow-checking `f`...
--> src/lib.rs:1:1
|
1 | const fn f() -> impl Eq { g() }
| ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing `f`...
--> src/lib.rs:1:1
|
1 | const fn f() -> impl Eq { g() }
| ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `f`...
--> src/lib.rs:1:1
|
1 | const fn f() -> impl Eq { g() }
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing whether `impl core::cmp::Eq` is freeze...
= note: ...which requires evaluating trait selection obligation `impl core::cmp::Eq: core::marker::Freeze`...
= note: ...which again requires computing type of `f::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> src/lib.rs:1:1
|
1 | const fn f() -> impl Eq { g() }
| ^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0391`.
Meta
rustc --version --verbose
:
rustc 1.62.1 (e092d0b6b 2022-07-16)
binary: rustc
commit-hash: e092d0b6b43f2de967af0887873151bb1c0b18d3
commit-date: 2022-07-16
host: x86_64-unknown-linux-gnu
release: 1.62.1
LLVM version: 14.0.5
rustc 1.64.0-nightly (6dbae3ad1 2022-07-25)
binary: rustc
commit-hash: 6dbae3ad19309bb541d9e76638e6aa4b5449f29a
commit-date: 2022-07-25
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
oli-obk
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedIssue: A query cycle occurred while none was expectedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.