Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird diagnostic for recursion in const fn #126408

Closed
dev-ardi opened this issue Jun 13, 2024 · 1 comment
Closed

Weird diagnostic for recursion in const fn #126408

dev-ardi opened this issue Jun 13, 2024 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dev-ardi
Copy link
Contributor

Code

const fn f() {
    const { f() };
}

Current output

error[E0391]: cycle detected when elaborating drops for `f`
 --> src/lib.rs:2:5
  |
2 |     const { f() };
  |     ^^^^^^^^^^^^^
  |
note: ...which requires simplifying constant for the type system `f::{constant#0}`...
 --> src/lib.rs:2:11
  |
2 |     const { f() };
  |           ^^^^^^^
note: ...which requires const-evaluating + checking `f::{constant#0}`...
 --> src/lib.rs:2:11
  |
2 |     const { f() };
  |           ^^^^^^^
note: ...which requires caching mir of `f` for CTFE...
 --> src/lib.rs:1:1
  |
1 | const fn f() {
  | ^^^^^^^^^^^^
  = note: ...which again requires elaborating drops for `f`, completing the cycle
  = note: cycle used when running analysis passes on this crate
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

For more information about this error, try `rustc --explain E0391`.

Desired output

No response

Rationale and extra context

const blocks are stable, the user shouldn't care about any of the information in the error.

Other cases

No response

Rust Version

❯ rustc --version --verbose
rustc 1.81.0-nightly (8337ba918 2024-06-12)
binary: rustc
commit-hash: 8337ba9189de188e2ed417018af2bf17a57d51ac
commit-date: 2024-06-12
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Anything else?

I couldn't try on 1.79.0

@dev-ardi dev-ardi added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 13, 2024
@theemathas
Copy link

Duplicate of #125713

@Nilstrieb Nilstrieb closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants