Open
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:
rust/compiler/rustc_borrowck/src/region_infer/mod.rs
Lines 743 to 759 in 425e142
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.