Skip to content

cycle detected when evaluating type-level constant on invalid return type #114918

Closed
@asquared31415

Description

@asquared31415

Code

// Does not repro without the braces.
#[allow(unused_braces)]
fn uwu() -> [(); { () }] {
    loop {}
}

Current output

error[[E0391]](https://doc.rust-lang.org/stable/error_codes/E0391.html): cycle detected when evaluating type-level constant
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
  |
note: ...which requires const-evaluating + checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires const-evaluating + checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires caching mir of `uwu::{constant#0}` for CTFE...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires elaborating drops for `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires borrow-checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires promoting constants in MIR for `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires const checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires preparing `uwu::{constant#0}` for borrow checking...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires unsafety-checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires building MIR for `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires match-checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires building THIR for `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
note: ...which requires type-checking `uwu::{constant#0}`...
 --> src/lib.rs:3:18
  |
3 | fn uwu() -> [(); { () }] {
  |                  ^^^^^^
  = note: ...which again requires evaluating type-level constant, completing the cycle
note: cycle used when checking that `uwu` is well-formed
 --> src/lib.rs:3:1
  |
3 | fn uwu() -> [(); { () }] {
  | ^^^^^^^^^^^^^^^^^^^^^^^^

Desired output

error[[E0308]](https://doc.rust-lang.org/stable/error_codes/E0308.html): mismatched types
 --> src/lib.rs:3:20
  |
3 | fn uwu() -> [(); { () }] {
  |                    ^^ expected `usize`, found `()`

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions