Skip to content

replace TypingEnv::post_analysis() with mir::Body::typing_env() - #164077

Draft
adwinwhite wants to merge 1 commit into
rust-lang:mainfrom
adwinwhite:phase-hack
Draft

adwinwhite wants to merge 1 commit into
rust-lang:mainfrom
adwinwhite:phase-hack

Conversation

@adwinwhite

@adwinwhite adwinwhite commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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 tries to use a separate field on mir::Body to track the typing mode.

r? lcnr

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 10, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

match self.phase {
MirPhase::Built | MirPhase::Analysis(_) => TypingEnv::new(
match self.typing_mode {
BodyTypingMode::Borrowck | BodyTypingMode::PostBorrowck => TypingEnv::new(

@lcnr lcnr Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when do we encounter this?

View changes since the review

/// us to see the difference and forego optimization on the inlined promoted items.
pub phase: MirPhase,

pub typing_mode: BodyTypingMode,

@lcnr lcnr Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment please :>

View changes since the review

StableHash,
TypeFoldable,
TypeVisitable
)]

@lcnr lcnr Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

View changes since the review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants