-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Fix ICE in normalization during closure capture analysis (#149746) #149800
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
base: main
Are you sure you want to change the base?
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
This comment has been minimized.
This comment has been minimized.
|
r? compiler |
|
|
|
|
This comment has been minimized.
This comment has been minimized.
| let input = self.typing_env.as_query_input(arg); | ||
|
|
||
| // 2. Use unwrap_or(arg) to return the original arg if it fails | ||
| self.tcx.try_normalize_generic_arg_after_erasing_regions(input).unwrap_or(arg) |
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.
we're intentionally using a bug! here as we're in normalize_generic_arg_after_erasing_regions.
The issue happens in the caller:
- we either have to change the caller to use
try_normalize...to avoid this ICE if the error is unavoidable - or prevent this error entirely by not calling
normalize_...for types which aren#t well-formed
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.
Thanks for the feedback @lcnr ! I have reverted the global change in rustc_middle and moved the fix to compiler/rustc_hir_typeck/src/upvar.rs as requested. specifically, I updated the needs_drop closure within has_significant_drop_outside_of_captures to use try_normalize_erasing_regions; if normalization fails, it now conservatively returns false (assuming no significant drop) instead of panicking.
3b0c42e to
fc87a13
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@lcnr anything else that needs to be changed? |
Co-authored-by: León Orell Valerian Liehr <[email protected]>
This fixes an internal compiler error that occurred when normalizing associated types during closure capture analysis.
The Fix: Modified rustc_middle/src/ty/normalize_erasing_regions.rs to gracefully handle projection normalization failures instead of panicking when analyzing closure captures.
Regression Test: Added tests/ui/associated-types/normalization-ice-issue-149746.rs, a reproduction case involving complex associated type projections (<() as Owner>::Ty) that previously crashed the compiler. Verified it now emits a standard type error (E0277).
Fixes #149746