Fix ICE #152205: upvar analysis with associated type projections#4
Open
Fix ICE #152205: upvar analysis with associated type projections#4
Conversation
The closure capture migration analysis (`rust_2021_incompatible_closure_captures`) hit `unreachable!()` in `has_significant_drop_outside_of_captures` when encountering associated type projections (`ty::Alias`). Three `unreachable!()` calls in `upvar.rs` assumed only certain type kinds and projection kinds would appear, but associated types like `<Foo as Trait>::Assoc` can produce unexpected patterns. Replace the panics with conservative fallbacks: - `unreachable!()` in filter_map closures → `None` (filter out) - `_ => unreachable!()` in main match → `false` (no significant drop) This is safe because the function is only used for the edition migration lint, so a conservative `false` just means we might miss a warning about incompatible closure captures, which is better than an ICE. Fixes rust-lang#152205
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.
Summary
Fix ICE in closure capture migration analysis when encountering associated type projections.
Problem
ICEs at
upvar.rs:1685withunreachable!().Fix
Replace three
unreachable!()calls with conservative fallbacks:unreachable!()in filter_map →None_ => unreachable!()→_ => falseSafe because this only affects the edition migration lint — conservative
falsemeans we might miss a warning, which is better than an ICE.Includes regression test.
Fixes rust-lang#152205