You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Activity
nikomatsakis commentedon May 17, 2016
cc @aturon @arielb1
we now handle higher-ranked subtyping correctly
we now handle higher-ranked subtyping correctly
work around rust-lang#33684, which affects NLL more than the old typeck
20 remaining items
tests: cases where we now do the right thing but did not before