Normalize capture place tys to prevent ICE#152165
Normalize capture place tys to prevent ICE#152165rust-bors[bot] merged 9 commits intorust-lang:mainfrom
tys to prevent ICE#152165Conversation
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?
a544343 to
176bf7d
Compare
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 🤔
a7ea420 to
c22ffdb
Compare
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 :>
c22ffdb to
88036b0
Compare
This comment has been minimized.
This comment has been minimized.
88036b0 to
7def3bc
Compare
|
I messed up by reviewing your commit directly yesterday, see c22ffdb#r177216090 |
7def3bc to
ecdea2c
Compare
This comment has been minimized.
This comment has been minimized.
5e5de59 to
dddbf96
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. |
|
(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?
|
@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.
|
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%) |
|
@bors r+ rollup |
Normalize capture place `ty`s to prevent ICE Fixes rust-lang#151579 Fixes rust-lang#120811 r? @lcnr
Normalize capture place `ty`s to prevent ICE Fixes rust-lang#151579 Fixes rust-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)
Fixes #151579
Fixes #120811
r? @lcnr