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:
|
// At this point we can pick any member of `choice_regions` and would like to choose |
|
// it to be a small as possible. To avoid potential non-determinism we will pick the |
|
// smallest such choice. |
|
// |
|
// Because universal regions are only partially ordered (i.e, not every two regions are |
|
// comparable), we will ignore any region that doesn't compare to all others when picking |
|
// the minimum choice. |
|
// |
|
// For example, consider `choice_regions = ['static, 'a, 'b, 'c, 'd, 'e]`, where |
|
// `'static: 'a, 'static: 'b, 'a: 'c, 'b: 'c, 'c: 'd, 'c: 'e`. |
|
// `['d, 'e]` are ignored because they do not compare - the same goes for `['a, 'b]`. |
|
let totally_ordered_subset = choice_regions.iter().copied().filter(|&r1| { |
|
choice_regions.iter().all(|&r2| { |
|
self.universal_region_relations.outlives(r1, r2) |
|
|| self.universal_region_relations.outlives(r2, r1) |
|
}) |
|
}); |
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.
Applying member constraints can result in overly strong constraints, causing the following test to fail:
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 compileThis may become a larger concern as we're working towards the new solver which introduces a significant amount of additional uses of opaques.