-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Resolved issue with mismatched types triggering ICE in certain scenarios #141236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
Aside, #141225 (currently open) includes an ICE test for this issue. Will need to coordinate depending on which lands first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of a shame that this hack needs to exist; the root cause is that we're leaking infer vars out of probes.
Is it possible instead to pass down the root type (i.e. the type of expr
itself) and the corresponding expected type, rather than looking into the TypeError
? This would mean we only detect this when the outermost type is &T
, but I don't think this diagnostic even knows how to apply to other cases?
Please also squash the commit history into one commit, since this is a pretty small change and doesn't need a complicated history.
Yeah, just rebase it and delete the test when it makes it onto master. Since this PR needs some tweaking, I think that PR will land first anyways. |
This comment has been minimized.
This comment has been minimized.
This PR changes a file inside |
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#139419 (Error on recursive opaque ty in HIR typeck) - rust-lang#141236 (Resolved issue with mismatched types triggering ICE in certain scenarios) - rust-lang#141253 (Warning added when dependency crate has async drop types, and the feature is disabled) - rust-lang#141269 (rustc-dev-guide subtree update) - rust-lang#141275 (`gather_locals`: only visit guard pattern guards when checking the guard) - rust-lang#141279 (`lower_to_hir` cleanups) - rust-lang#141285 (Add tick to `RePlaceholder` debug output) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#141236 - jagunter:issue-140823, r=compiler-errors Resolved issue with mismatched types triggering ICE in certain scenarios ## Background The function `annotate_mut_binding_to_immutable_binding` called in `emit_coerce_suggestions` performs a type comparison between the `expected` and `found` types from `ExpectedFound` in the `TypeError`. This can fail if the `found` type contains a region variable that's been rolled back. ## What is being changed? This updates `annotate_mut_binding_to_immutable_binding` to use `expr_ty` and `expected` from the parent function instead of the types from the `TypeError`. This sidesteps the issue of using `found` from `TypeError` which may leak lingering inference region variables. This does change the diagnostic behavior to _only_ support cases where the expected outermost type is `&T`, but that seems to be the intended functionality. Also fixed the example in the `annotate_mut_binding_to_immutable_binding` rustdocs. r? rust-lang/types Fixes rust-lang#140823
Background
The function
annotate_mut_binding_to_immutable_binding
called inemit_coerce_suggestions
performs a type comparison between theexpected
andfound
types fromExpectedFound
in theTypeError
. This can fail if thefound
type contains a region variable that's been rolled back.What is being changed?
This updates
annotate_mut_binding_to_immutable_binding
to useexpr_ty
andexpected
from the parent function instead of the types from theTypeError
. This sidesteps the issue of usingfound
fromTypeError
which may leak lingering inference region variables.This does change the diagnostic behavior to only support cases where the expected outermost type is
&T
, but that seems to be the intended functionality.Also fixed the example in the
annotate_mut_binding_to_immutable_binding
rustdocs.r? rust-lang/types
Fixes #140823