Skip to content

2025-07-18 regression: cycle detected when computing revealed normalized predicates #144690

@nazar-pc

Description

@nazar-pc

Code

I do not have a minimized reproduction, but here is a branch: https://github.com/nazar-pc/abundance/tree/rustc-regression-144690

Reproduction:

cd subspace/crates/subspace-farmer
cargo clippy --no-default-features --lib

I apologize upfront for the number of dependencies there.

I expected to see this happen: clippy check is successful.

Instead, this happened:

error[E0391]: cycle detected when computing revealed normalized predicates of `ab_farmer_components::reading::read_sector_record_chunks::{constant#0}`
   --> abundance/crates/farmer/ab-farmer-components/src/reading.rs:139:30
    |
139 |     s_bucket_offsets: &[u32; Record::NUM_S_BUCKETS],
    |                              ^^^^^^^^^^^^^^^^^^^^^
    |
note: ...which requires computing normalized predicates of `ab_farmer_components::reading::read_sector_record_chunks::{constant#0}`...
   --> abundance/crates/farmer/ab-farmer-components/src/reading.rs:139:30
    |
139 |     s_bucket_offsets: &[u32; Record::NUM_S_BUCKETS],
    |                              ^^^^^^^^^^^^^^^^^^^^^
    = note: ...which again requires computing revealed normalized predicates of `ab_farmer_components::reading::read_sector_record_chunks::{constant#0}`, completing the cycle
note: cycle used when looking up the hidden types stored across await points in a coroutine
   --> abundance/crates/farmer/ab-farmer-components/src/reading.rs:451:1
    |
451 | / {
452 | |     let pieces_in_sector = sector_metadata.pieces_in_sector;
453 | |
454 | |     let sector_contents_map = {
...   |
506 | |     Ok(piece.to_shared())
507 | | }
    | |_^
    = 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`.
error: could not compile `subspace-farmer` (lib) due to 1 previous error

Offending function signature:

pub async fn read_sector_record_chunks<PosTable, S, A>(
    piece_offset: PieceOffset,
    pieces_in_sector: u16,
    s_bucket_offsets: &[u32; Record::NUM_S_BUCKETS],
    sector_contents_map: &SectorContentsMap,
    pos_table: &PosTable,
    sector: &ReadAt<S, A>,
    mode: ReadSectorRecordChunksMode,
) -> Result<Box<[Option<RecordChunk>; Record::NUM_S_BUCKETS]>, ReadingError>
where
    PosTable: Table,
    S: ReadAtSync,
    A: ReadAtAsync,
{

The associated constant it doesn't like is in turn an expression too:

impl Record {
    pub const NUM_CHUNKS: usize = 2_usize.pow(15);
    pub const NUM_S_BUCKETS: usize = Record::NUM_CHUNKS
        * RecordedHistorySegment::ERASURE_CODING_RATE.1
        / RecordedHistorySegment::ERASURE_CODING_RATE.0;
}
// ...
impl RecordedHistorySegment {
    pub const ERASURE_CODING_RATE: (usize, usize) = (1, 2);

The only workaround I found so far is to replace s_bucket_offsets: &[u32; Record::NUM_S_BUCKETS], with s_bucket_offsets: &[u32; 65536],. Using constants of any kind doesn't seem to compile anymore.

Version it worked on

It most recently worked on:

rustc 1.90.0-nightly (e46629662 2025-07-17)
binary: rustc
commit-hash: e4662966273ed58b51f9ff8d682accc202aa1210
commit-date: 2025-07-17
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

Version with regression

rustc --version --verbose:

rustc 1.90.0-nightly (8f08b3a32 2025-07-18)
binary: rustc
commit-hash: 8f08b3a32478b8d0507732800ecb548a76e0fd0c
commit-date: 2025-07-18
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions