Skip to content

parallel compiler: async fns not reproducible #162202

Description

@matthiaskrgr

I tried this code:

async fn test1(_: &'_ u8) {}
async fn test2<'s>(_: &'s u8,) {}
fn main() {}

rustc --edition=2024 -Zremap-cwd-prefix=reproducible_dir -Ccodegen-units=1 -Zthreads=30 --crate-type=lib --crate-name=test -o out ; md5sum out

I expected to see this happen:
constant md5sum

Instead, this happened:
the md5sum is flipflopping between d1afc31db4a80828c5c3937fae627a66 and 56d12483eea2eaaca0cd435f83439b59

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (5db7f4be8 2026-09-01)
binary: rustc
commit-hash: 5db7f4be8a36c1b8ae19299469e2be2b0f052c21
commit-date: 2026-09-01
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 2, 2026
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 2, 2026
  3. matthiaskrgr commented on Sep 2, 2026

    @matthiaskrgr
    MemberAuthor

    hmm the problem may be that RPIT already is not reproducible 🤔

    trait Foo {
        fn test() -> impl IntoIterator<Item = ()> + Send;
    }
    
    struct A;
    impl Foo for A {
        fn test() -> impl IntoIterator<Item = ()> + Send {
            []
        }
    }
    
    struct B;
    impl Foo for B {
        fn test() -> impl IntoIterator<Item = ()> + Send {
            []
        }
    }
    
    fn main() {}
    c264c8aa81fb4ed39014b7cda7ad1246  out
    13aa0ad3cdf07b23e8982f2adde770ba  out
    c264c8aa81fb4ed39014b7cda7ad1246  out
    c264c8aa81fb4ed39014b7cda7ad1246  out
    13aa0ad3cdf07b23e8982f2adde770ba  out
    13aa0ad3cdf07b23e8982f2adde770ba  out
    13aa0ad3cdf07b23e8982f2adde770ba  out
    13aa0ad3cdf07b23e8982f2adde770ba  out
    c264c8aa81fb4ed39014b7cda7ad1246  out
    
  4. changed the title [-]async fns not reproducible[/-] [+]parallel compiler: async fns not reproducible[/+] on Sep 2, 2026
  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 3, 2026
  6. susitsm commented on Sep 8, 2026

    @susitsm
    Contributor

    I tracked down an issue with RPIT, not sure about the solution yet

    The DefIndex of these anon associated types is nondeterministic

     DefIndex(18) DefId(0:18 ~ test[d7b8]::{impl#0}::test::{anon_assoc#0}), def_key DefKey { parent: Some(DefIndex(8)), disambiguated_data: DisambiguatedDefPathData { data: AnonAssocTy("test"), disambiguator: 0 } }, def_path_hash DefPathHash(Fingerprint(15544225586418147366, 3099408607842894160))
     DefIndex(18) DefId(0:18 ~ test[d7b8]::{impl#1}::test::{anon_assoc#0}), def_key DefKey { parent: Some(DefIndex(13)), disambiguated_data: DisambiguatedDefPathData { data: AnonAssocTy("test"), disambiguator: 0 } }, def_path_hash DefPathHash(Fingerprint(15544225586418147366, 13768408182880456915))
    

    The DefIndex of RPITIT types is created lazily in associated_type_for_impl_trait_in_impl called from the associated_types_for_impl_traits_in_trait_or_impl query which is called from associated_item_def_ids. Some of these are likely called in parallel during type checking, racing which assoc item gets DefIndex 18.

  7. susitsm commented on Sep 8, 2026

    @susitsm
    Contributor

    There are more cases where DefId-s are synthesized in queries: coroutine_by_move_body_def_id and intern_as_new_static both call create_def.
    coroutine_by_move_body_def_id and the RPITIT ones seem solvable by calling these queries in deterministic order.
    inter_as_new_static is different. The function is part of const eval and takes an AllocId as an input which is not deterministic AFAIK. There is a good chance this is related to #162203

  8. added 2 commits that reference this issue on Sep 11, 2026
  9. added a commit that references this issue on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-parallel-compilerArea: parallel compilerA-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.T-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