`apply_member_constraints` is incomplete
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Applying member constraints can result in overly strong constraints, causing the following test to fail:
fn new_defining_use<'a, F: FnOnce(T) -> &'a (), T>(_: F) {}
fn rpit<'a, 'b: 'b>(x: &'b ()) -> impl Sized + use<'a, 'b> {
// currently a separate defining use, chooses `'static`
new_defining_use(rpit::<'a, 'b>);
x // this defining use needs to be `&'b ()`
}
This is caused by the following code:
This sort of incompleteness is unfortunately required as we can use this to lift otherwise unconstrained regions to 'static, e.g. the following snippet otherwise fails to compile
fn foo<'a, 'b>() -> impl Sized + use<'a, 'b> {
&()
}
This may become a larger concern as we're working towards the new solver which introduces a significant amount of additional uses of opaques.
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 reading the linked apply_member_constraints code in compiler/rustc_borrowck/src/region_infer/mod.rs around lines 743-759. Reproduce both Rust snippets and trace how defining uses choose region constraints; done means the rpit case avoids an overly strong constraint while the unconstrained-region example still does not lift regions to 'static.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100