diagnostics flipflopping with Zthreads
Open
Nobody has claimed this yet.
A-diagnostics
A-parallel-compiler
A-reproducibility
C-bug
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the two-trait reproducer with rustc --edition=2024 -Zthreads=8 --crate-type=lib and compare the two reported diagnostics. Investigate the compiler query and diagnostic paths involved in trait dyn-compatibility and function-signature checking; done means the same appropriate diagnostics are produced consistently.
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