Skip to content

Cycle error involving Freeze when testing time crate #119273

Open
@jhpratt

Description

@jhpratt

For roughly a month, I have been getting an error in CI when performing code coverage. This is due to a stderr diff (I'm using trybuild). By itself, that is acceptable breakage, but the cause is a cycle error. Given the most recent successful and earliest failing CI runs, I bisected the compiler. The results are below. I have not attempted to minimize the error in any way.

In my opinion, a cycle error like this should be a proper ICE in terms of diagnostics, which would tell the user to file an issue. I only know to do this because of my involvement with rustc.

This change will land on stable in just a few days. I have reproduced it on the 1.75.0 binary from the pre-release server.

cc @compiler-errors as author of the PR apparently causing regression (#117418)

The diff in question:

diff --git a/tests/compile-fail/invalid_serializer.stderr b/tests/compile-fail/invalid_serializer.stderr
index 2f73f41..3579ac3 100644
--- a/tests/compile-fail/invalid_serializer.stderr
+++ b/tests/compile-fail/invalid_serializer.stderr
@@ -79,3 +79,35 @@ error[E0432]: unresolved import `not_string`
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `not_string`
    |
    = note: this error originates in the macro `serde::format_description` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0391]: cycle detected when computing type of opaque `my_format::description::{opaque#0}`
+  --> ../tests/compile-fail/invalid_serializer.rs:14:1
+   |
+14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires borrow-checking `my_format::description`...
+  --> ../tests/compile-fail/invalid_serializer.rs:14:1
+   |
+14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires promoting constants in MIR for `my_format::description`...
+  --> ../tests/compile-fail/invalid_serializer.rs:14:1
+   |
+14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires const checking `my_format::description`...
+  --> ../tests/compile-fail/invalid_serializer.rs:14:1
+   |
+14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which requires computing whether `my_format::description::{opaque#0}` is freeze...
+   = note: ...which requires evaluating trait selection obligation `my_format::description::{opaque#0}: core::marker::Freeze`...
+   = note: ...which again requires computing type of opaque `my_format::description::{opaque#0}`, completing the cycle
+note: cycle used when computing type of `my_format::description::{opaque#0}`
+  --> ../tests/compile-fail/invalid_serializer.rs:14:1
+   |
+14 | serde::format_description!(my_format, OffsetDateTime, not_string); // string format wrong type
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = 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
+   = note: this error originates in the macro `serde::format_description` (in Nightly builds, run with -Z macro-backtrace for more info)

@rustbot label +C-bug +regression-from-stable-to-beta +T-compiler


searched nightlies: from nightly-2023-10-20 to nightly-2023-11-19
regressed nightly: nightly-2023-11-08
searched commit range: 189d6c7...7adc89b
regressed commit: 504f63e

bisected with cargo-bisect-rustc v0.6.7

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2023-10-20 --end 2023-11-19 --script ./test.sh 

./test.sh contains:

#!/bin/sh

RUSTFLAGS="--cfg __ui_tests" cargo test --all-features

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions