auto trait leakage diagnostics is outdated and incorrect for indirect cycles
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
fn is_send<T: Send>(_: T) {}
fn foo() -> impl Sized {
is_send(bar());
1
}
fn bar() -> impl Sized {
is_send(foo());
2
}
results in a query cycle. We stash this query cycle and overwrite it with a nicer diagnostic:
error: cannot check whether the hidden type of opaque type satisfies auto traits
--> src/lib.rs:8:13
|
8 | is_send(foo());
| ------- ^^^^^
| |
| required by a bound introduced by this call
|
= note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
note: opaque type is declared here
--> src/lib.rs:3:13
|
3 | fn foo() -> impl Sized {
| ^^^^^^^^^^
note: required by a bound in `is_send`
--> src/lib.rs:2:15
|
2 | fn is_send<T: Send>(_: T) {}
| ^^^^ required by this bound in `is_send`
This diagnostic has 2 issues:
fetching the hidden types of an opaque inside of the defining scope
We're never doing that. There are two typeck queries involved in the cycle. Talking about "in the defining scope" isn't right, it should be "fetching the hidden types of opaque types depends on type inference of its defining scopes"
You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
This part of the diagnostic was relevant for TAIT but doesn't help for RPIT(IT) and with explicit define_opaque attributes. We should remove it
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
Reproduce the indirect-cycle example in src/lib.rs and trace the two typeck queries involved in the cycle. Find the diagnostic for auto-trait leakage, change its wording to describe dependence on type inference in the defining scopes, and remove the TAIT-specific submodule suggestion. Verify that the resulting diagnostic matches the requested behavior.
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
- 45/100