Description
Branching off from #32330. The current subtyping rules for higher-ranked regions are overly conservative, with the result that a function declaration like this:
fn foo<'a>() -> &'a i32
is not equivalent to
fn foo() -> &'static i32
This exaggerates the impact of #32330 because functions like
fn foo<'a>(&self) -> &'a i32
must be converted to the form
fn foo<'a>(&'a self) -> &'a i32
in some cases, which feels a bit silly.
I proposed a fix in #32330 (described in some detail here), however I decided to hold off and land that fix separately, when I had more time to polish it (and consider it). In the meantime, this does mean that we wind up with more warnings than we otherwise would.
There is some mild backcompat risk in that the current coherence rules will allow you to distinguish between types on the basis of bound regions, but in some cases that is wrong. It is probably worth modifying coherence so that it doesn't distinguish bound regions at all -- or better yet, operates with fully erased regions.