rust-lang / rust-lang/rust

Cycle error involving `Freeze` when testing `time` crate

Open
#119,273 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-bug I-cycle P-medium regression-from-stable-to-stable T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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: https://github.com/rust-lang/rust/compare/189d6c71f3bb6c52113b5639a80839791974fd22...7adc89b69b941afceadcf8609dd6b2999353e550
regressed commit: https://github.com/rust-lang/rust/commit/504f63efb0d5dd4cc22f5a43460b3b343d959b27

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/compile-fail/invalid_serializer.rs, its invalid_serializer.stderr baseline, and ./test.sh, which runs the affected trybuild-style tests with RUSTFLAGS="--cfg __ui_tests". Reproduce the cycle error with cargo test or the provided cargo bisect-rustc command, then compare behavior around the bisected regression commit. Done means the invalid input no longer produces the problematic cycle diagnostic and the expected stderr test passes with appropriate compiler diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.