Equate fn outputs when inferring RPITIT hidden types #101614
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we are trying to infer the hidden types for RPITITs, we need to equate the output tys instead of just subtyping them. For example:
If we just subtype the signatures
fn() -> &'static str <: fn() -> _#1t
(where_#1t
is the variable we've used to inferimpl Sized
), we'll end up&'static str <: _#1t
, which causes us to infer_#1t = #'_#2r str
, where'_#2r
is unconstrained, which gets fixed up toReEmpty
, and which is certainly not what we want.I can't actually think of a way to make this fail to compile, because during borrowck we've already done the method probe, and so we just look at the
impl
method signature and see the&'static str
any time we call<() as Foo>::bar()
. But this does cause the ICE here in @jackh726's "Remove ReEmpty" PR (#98559) to stop ICEing, because after that PR we were leaking unconstrained region variables into the typeck results.r? types