Skip to content

diagnostics flipflopping with Zthreads #142063

Open
@matthiaskrgr

Description

@matthiaskrgr

I tried this code:

trait A { fn foo() -> A; }
trait B { fn foo() -> A; }

I expected to see this happen:
consistent diagnostics

Instead, this happened:
compiling with --edition=2024 -Zthreads=8 --crate-type=lib

sometimes rustc prints

error[E0391]: cycle detected when computing function signature of `A::foo`
 --> b.rs:1:11
  |
1 | trait A { fn foo() -> A; }
  |           ^^^^^^^^^^^^^^
  |
note: ...which requires checking if trait `A` is dyn-compatible...
 --> b.rs:1:1
  |
1 | trait A { fn foo() -> A; }
  | ^^^^^^^
note: ...which requires determining dyn-compatibility of trait `A`...
 --> b.rs:1:1
  |
1 | trait A { fn foo() -> A; }
  | ^^^^^^^
  = note: ...which again requires computing function signature of `A::foo`, completing the cycle
note: cycle used when checking that `A::foo` is well-formed
 --> b.rs:1:11
  |
1 | trait A { fn foo() -> A; }
  |           ^^^^^^^^^^^^^^
  = 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

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.

but other times it prints

error[E0782]: expected a type, found a trait
 --> b.rs:1:23
  |
1 | trait A { fn foo() -> A; }
  |                       ^
  |
help: `A` is dyn-incompatible, use `impl A` to return an opaque type, as long as you return a single underlying type
  |
1 | trait A { fn foo() -> impl A; }
  |                       ++++

error[E0782]: expected a type, found a trait
 --> b.rs:2:23
  |
2 | trait B { fn foo() -> A; }
  |                       ^
  |
help: `A` is dyn-incompatible, use `impl A` to return an opaque type, as long as you return a single underlying type
  |
2 | trait B { fn foo() -> impl A; }
  |                       ++++

error: associated item referring to unboxed trait object for its own trait
 --> b.rs:1:23
  |
1 | trait A { fn foo() -> A; }
  |       - in this trait ^
  |
help: you might have meant to use `Self` to refer to the implementing type
  |
1 - trait A { fn foo() -> A; }
1 + trait A { fn foo() -> Self; }
  |

error: aborting due to 3 previous errors

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (4b27a04cc 2025-06-04)
binary: rustc
commit-hash: 4b27a04cc8ed4da10a546a871e23e665d03f7a79
commit-date: 2025-06-04
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-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