`deduce_closure_signature` fails in with ambiguous self-referential aliases
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
trait Foo<'a> {
type Input;
}
impl<'a, F: Fn(&'a u32)> Foo<'a> for F {
type Input = &'a u32;
}
fn needs_super<F: for<'a> Fn(<F as Foo<'a>>::Input) + for<'a> Foo<'a>>(_: F) {}
fn main() {
needs_super(|_: &u32| {}); // doesn't need deduce sig rn
needs_super(|_| {}); // fails with old solver
}
taken from https://github.com/rust-lang/trait-system-refactor-initiative/issues/191#issuecomment-3307163025
We currently don't decide the closure signature for needs_super even though we have a ?expectation: for<'a> Fn(<?expectation as Foo<'a>>::Input). Doing this properly relies on higher-kinded inference variables.
With higher-kinded infer vars, we could set the closure signature to ?inf[?expectation, 'a] and constrain that infer var via a Projection(<?expectation as Foo<'!a>>::Input, [?expectation, '!a]) goal (where '!a is a placeholder.
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 with the self-contained Rust reproducer around needs_super and confirm that the closure without an explicit parameter type fails during deduce_closure_signature. Read the linked trait-system refactor discussion and investigate the higher-kinded inference-variable requirement. Done means the ambiguous self-referential alias case can infer the closure signature successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100