Uh oh!
There was an error while loading. Please reload this page.
Normalize capture place tys to prevent ICE - #152165
Conversation
This comment has been minimized.
This comment has been minimized.
| HirPlaceBase::Upvar(upvar_id) => { | ||
| ty::TypingEnv::post_analysis(tcx, upvar_id.closure_expr_id) | ||
| } | ||
| _ => ty::TypingEnv::fully_monomorphized(), |
There was a problem hiding this comment.
This is hacky and subtly wrong in two ways.
- even if the type is not from an upvar, we still need the right param_env to normalize
- we use this during MIR build, so it should probably use
TypingMode::Borrowckor whatever
see https://rustc-dev-guide.rust-lang.org/typing-parameter-envs.html
There was a problem hiding this comment.
Ah I see, I've switched to use try_structurally_resolve_ty as mentioned in the issue: 176bf7d (this PR)
This way, we can avoid deep normalization here, right?
This comment has been minimized.
This comment has been minimized.
| } | ||
| fn try_structurally_resolve_place_ty(&self, span: Span, place: &mut Place<'tcx>) { | ||
| place.base_ty = self.try_structurally_resolve_type(span, place.base_ty); |
There was a problem hiding this comment.
use deeply_normalize here. We deeply normalize types in the writeback results, so I think we should do the same here
There was a problem hiding this comment.
Just replacing didn't work so I had to do something like this instead: 750cd53
Is this what you meant for?
There was a problem hiding this comment.
can you use at.deeply_normalize with both solvers?
There was a problem hiding this comment.
I've tried but had to construct TraitEngine there which seems an unusual way (I haven't seen such a way in other places).
Instead, I guess using ObligationCtxt might be better here, other places do this way and it shoudl call at.deeply_normalize internally: a7ea420
How about this?
| UpvarMigrationInfo::CapturingPrecise { | ||
| source_expr: capture.info.path_expr_id, | ||
| var_name: capture.to_string(self.tcx), | ||
| var_name: self.place_to_string_for_migration(capture), |
There was a problem hiding this comment.
can we move this normalization even further up so that catpure.place is already deeply normalized and we don't have to do so here?
There was a problem hiding this comment.
Moved: c22ffdb
I wonder if we should reduce scope by if next_solver as we now normalize stuff more generally, i.e. other than emitting lint rust_2021_incompatible_closure_captures and it would bring unnecessary cost for most cases 🤔
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } | ||
| } | ||
| fn try_structurally_resolve_place_ty(&self, span: Span, place: &mut Place<'tcx>) { |
There was a problem hiding this comment.
deeply_normalize should normalize arbitrary TypeFoldable things. Is Place type foldable?
Also, change this function name :>
This comment has been minimized.
This comment has been minimized.
lcnr
commented
Feb 15, 2026
I messed up by reviewing your commit directly yesterday, see c22ffdb#r177216090 |
This comment has been minimized.
This comment has been minimized.
JohnTitor
commented
Feb 16, 2026
Uh oh!
There was an error while loading. Please reload this page.
rustbot
commented
Feb 17, 2026
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. |
JohnTitor
commented
Feb 17, 2026
(rebase mistake, sorry for pinging) |
| let at = self.at(&cause, self.param_env); | ||
| match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals( | ||
| at, | ||
| place.clone(), |
There was a problem hiding this comment.
i guess to return some place in the error case?
lcnr
commented
Feb 26, 2026
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Normalize capture place `ty`s to prevent ICE
This comment has been minimized.
This comment has been minimized.
rust-timer
commented
Feb 26, 2026
Finished benchmarking commit (00ebd52): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -3.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 480.119s -> 482.867s (0.57%) |
lcnr
commented
Feb 27, 2026
@bors r+ rollup |
Normalize capture place `ty`s to prevent ICE Fixesrust-lang#151579Fixesrust-lang#120811 r? @lcnr
Normalize capture place `ty`s to prevent ICE Fixesrust-lang#151579Fixesrust-lang#120811 r? @lcnr
…uwer Rollup of 12 pull requests Successful merges: - #153211 (`rust-analyzer` subtree update) - #149027 (Improve cross-crate trait impl param mismatch suggestions ) - #152730 (add field representing types) - #153136 (Correctly handle `#[doc(alias = "...")]` attribute on inlined reexports) - #152165 (Normalize capture place `ty`s to prevent ICE) - #152615 (refactor 'valid for read/write' definition: exclude null) - #153109 (Fix LegacyKeyValueFormat report from docker build: aarch64-gnu-debug) - #153172 (Fix comment about placeholders) - #153187 (Fix ICE when macro-expanded extern crate shadows std) - #153190 (Don't allow subdiagnostic to use variables from their parent) - #153200 (Remove redundant clone) - #153216 (mark two polonius tests as known-bug)
Uh oh!
There was an error while loading. Please reload this page.
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#153211 (`rust-analyzer` subtree update) - rust-lang/rust#149027 (Improve cross-crate trait impl param mismatch suggestions ) - rust-lang/rust#152730 (add field representing types) - rust-lang/rust#153136 (Correctly handle `#[doc(alias = "...")]` attribute on inlined reexports) - rust-lang/rust#152165 (Normalize capture place `ty`s to prevent ICE) - rust-lang/rust#152615 (refactor 'valid for read/write' definition: exclude null) - rust-lang/rust#153109 (Fix LegacyKeyValueFormat report from docker build: aarch64-gnu-debug) - rust-lang/rust#153172 (Fix comment about placeholders) - rust-lang/rust#153187 (Fix ICE when macro-expanded extern crate shadows std) - rust-lang/rust#153190 (Don't allow subdiagnostic to use variables from their parent) - rust-lang/rust#153200 (Remove redundant clone) - rust-lang/rust#153216 (mark two polonius tests as known-bug)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#153211 (`rust-analyzer` subtree update) - rust-lang/rust#149027 (Improve cross-crate trait impl param mismatch suggestions ) - rust-lang/rust#152730 (add field representing types) - rust-lang/rust#153136 (Correctly handle `#[doc(alias = "...")]` attribute on inlined reexports) - rust-lang/rust#152165 (Normalize capture place `ty`s to prevent ICE) - rust-lang/rust#152615 (refactor 'valid for read/write' definition: exclude null) - rust-lang/rust#153109 (Fix LegacyKeyValueFormat report from docker build: aarch64-gnu-debug) - rust-lang/rust#153172 (Fix comment about placeholders) - rust-lang/rust#153187 (Fix ICE when macro-expanded extern crate shadows std) - rust-lang/rust#153190 (Don't allow subdiagnostic to use variables from their parent) - rust-lang/rust#153200 (Remove redundant clone) - rust-lang/rust#153216 (mark two polonius tests as known-bug)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#153211 (`rust-analyzer` subtree update) - rust-lang/rust#149027 (Improve cross-crate trait impl param mismatch suggestions ) - rust-lang/rust#152730 (add field representing types) - rust-lang/rust#153136 (Correctly handle `#[doc(alias = "...")]` attribute on inlined reexports) - rust-lang/rust#152165 (Normalize capture place `ty`s to prevent ICE) - rust-lang/rust#152615 (refactor 'valid for read/write' definition: exclude null) - rust-lang/rust#153109 (Fix LegacyKeyValueFormat report from docker build: aarch64-gnu-debug) - rust-lang/rust#153172 (Fix comment about placeholders) - rust-lang/rust#153187 (Fix ICE when macro-expanded extern crate shadows std) - rust-lang/rust#153190 (Don't allow subdiagnostic to use variables from their parent) - rust-lang/rust#153200 (Remove redundant clone) - rust-lang/rust#153216 (mark two polonius tests as known-bug)
Fixes#151579
Fixes#120811
r? @lcnr