Skip to content

Chained ifs through to MIR generation#393

Merged
thepowersgang merged 16 commits into
masterfrom
chained_ifs
Mar 8, 2026
Merged

Chained ifs through to MIR generation#393
thepowersgang merged 16 commits into
masterfrom
chained_ifs

Conversation

@thepowersgang

@thepowersgang thepowersgang commented Mar 1, 2026

Copy link
Copy Markdown
Owner

With the addition of partial support for if let guards in the 1.90 update (or earlier, memory fails me) - it seems like a good idea to lower if and if-let chains from AST into match () { _ if foo => ... - Removing a large amount of code in the process.

Why:

  • Simplifies HIR stage (removing a node type)
  • Avoids false warnings with if let including irrefutable patterns.
  • Opportunity to clean up match guards

Changes:

  • AST: Unified if and if let into a single construct that encodes a if-else-if-else chain as one node
  • AST: Split ExprNode_Loop out into nodes for loop, for and while (let), as the while let support uses the same structures as the new if node.
  • Expand: Remove expand-level de-sugaring of if let
  • Expand: Remove dead code in proc_macro handling.
  • HIR: Remove if from HIR, replaced with match
  • MIR: Rewrite match generation to have correct variable state tracking (I think, still running full test)
  • MIR: Unified both copies of MIR monomorphisation code (Optimise and Monomorph) into one construct, now used in MIR match lowering.

@thepowersgang thepowersgang changed the title DRAFT: Chained ifs through to MIR generation Chained ifs through to MIR generation Mar 1, 2026
@thepowersgang
thepowersgang marked this pull request as ready for review March 7, 2026 06:29
@thepowersgang

Copy link
Copy Markdown
Owner Author

Waiting on a final test of 1.90 bootstrap

@thepowersgang

Copy link
Copy Markdown
Owner Author

Bootstrap completed for 1.90, binary equal.
Merging.

@thepowersgang
thepowersgang merged commit 9f5ff51 into master Mar 8, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant