Repository navigation
replace TypingEnv::post_analysis() with mir::Body::typing_env() - #164077
adwinwhite wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
2d08b00 to
0b642e2
Compare
This comment has been minimized.
This comment has been minimized.
0b642e2 to
53c2b35
Compare
| match self.phase { | ||
| MirPhase::Built | MirPhase::Analysis(_) => TypingEnv::new( | ||
| match self.typing_mode { | ||
| BodyTypingMode::Borrowck | BodyTypingMode::PostBorrowck => TypingEnv::new( |
There was a problem hiding this comment.
when do we encounter this?
There was a problem hiding this comment.
The initial mode is BodyTypingMode::Borrowck. After mir_borrowck, we set it to PostBorrowck.
There was a problem hiding this comment.
promote_consts pass would use BodyTypingMode::Borrowck since it's run before borrowck.
| /// us to see the difference and forego optimization on the inlined promoted items. | ||
| pub phase: MirPhase, | ||
|
|
||
| pub typing_mode: BodyTypingMode, |
There was a problem hiding this comment.
comment please :>
| StableHash, | ||
| TypeFoldable, | ||
| TypeVisitable | ||
| )] |
There was a problem hiding this comment.
should also have a comment, or maybe just change the field to go "see [BodyTypingMode] for more info"
also, mind splitting the derive in two so that it doesn't get spread out like this
5e23058 to
23a44a9
Compare
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
| #[derive(Copy, Clone, PartialEq, Debug)] | ||
| #[derive(TyEncodable, TyDecodable, StableHash, TypeFoldable, TypeVisitable)] | ||
| pub enum BodyTypingMode { | ||
| Borrowck, |
There was a problem hiding this comment.
| // This branch happens for drop glue and fn ptr shims. | ||
| // FIXME: why do we do any of this analysis on drop glue etc? | ||
| // This should ideally all be skipped. | ||
| TypingEnv::post_analysis(tcx, self.source.def_id()) |
There was a problem hiding this comment.
should this be the case or could we change drop glue and fn ptr shims to just start out in TypingMode::PostAnalysis?
There was a problem hiding this comment.
We already use PostAnalysis mode for them. I guess this branch is actually useless.
|
|
||
| debug!("runtime_mir_cleanup({:?})", did); | ||
| run_runtime_cleanup_passes(tcx, body); | ||
| assert!(body.typing_mode == BodyTypingMode::PostAnalysis, "{:?}", body.typing_mode); |
There was a problem hiding this comment.
| // We try to guard against future MIR building procedures that don't go through the usual | ||
| // lowering. The final validation is expected to run in `TypingMode::PostAnalysis`. | ||
| if new_phase == MirPhase::Runtime(RuntimePhase::Optimized) { | ||
| assert_eq!(body.typing_mode, BodyTypingMode::PostAnalysis,); |
There was a problem hiding this comment.
| assert_eq!(body.typing_mode, BodyTypingMode::PostAnalysis,); | |
| assert_eq!(body.typing_mode, BodyTypingMode::PostAnalysis); |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
23a44a9 to
a5cc7e2
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. |
This comment has been minimized.
This comment has been minimized.
a5cc7e2 to
4bbe3be
Compare
Similar to #163745
We should discourage constructing a typing env by hand when it can be derived from context.
This simplifies reasoning and reduces the mistake of not resetting rigidness markers across typing envs.
This PR adds a field to
mir::Bodyto track the typing mode.r? lcnr