Don't ICE in has_self_borrows when coroutine captures-by-ref ty is still inferred#156266
Open
swjng wants to merge 1 commit intorust-lang:mainfrom
Open
Don't ICE in has_self_borrows when coroutine captures-by-ref ty is still inferred#156266swjng wants to merge 1 commit intorust-lang:mainfrom
swjng wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Collaborator
|
…ill inferred `coroutine_captures_by_ref_ty` is a fresh `next_ty_var` until upvar inference unifies it to an `FnPtr`. Reaching `has_self_borrows` before that hits the `_ => panic!()` arm. Treat `Infer` like `Error` so the closure falls back to `FnOnce`-only.
0cc1ef4 to
8f5440d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #155999.
coroutine_captures_by_ref_tyis a freshnext_ty_varuntil upvarinference unifies it to an
FnPtr. Ifhas_self_borrowsis reachedbefore that — e.g. when the body contains an unresolved
as _cast —the
_ => panic!()arm fires:Treat the
Infercase likeError: report self-borrows defensivelyso the closure falls back to
FnOnce-only and the caller surfaces anormal type-inference error instead of an ICE.