Skip to content

Conversation

@indietyp
Copy link
Member

@indietyp indietyp commented Jan 3, 2026

🌟 What is the purpose of this PR?

This PR optimizes empty tuple handling in the MIR by simplifying empty tuple aggregates to unit constants and fixing tuple type handling in the body builder macro.

🔍 What does this change?

  • Added From<!> implementation for Operand<'_> to support empty tuples
  • Fixed tuple type handling in the body builder macro to properly handle empty tuples
  • Added support for empty tuples in the rvalue macro
  • Added optimization in the instruction simplifier to convert empty tuple aggregates to unit constants
  • Added a test case to verify empty tuple simplification
  • Sorted feature flags in lib.rs for better organization
  • Updated test outputs to reflect the new optimizations

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • Added a specific test case empty_tuple_to_unit() to verify the optimization
  • Existing test outputs have been updated to reflect the changes

❓ How to test this?

  1. Run the MIR tests to verify that empty tuples are properly optimized
  2. Check that the updated test outputs match the expected behavior

@vercel vercel bot temporarily deployed to Preview – petrinaut January 3, 2026 14:33 Inactive
@cursor
Copy link

cursor bot commented Jan 3, 2026

PR Summary

Introduces canonical handling of empty tuples as unit across MIR construction and optimization.

  • Add From<!> for Operand to enable zero-arg tuple paths
  • Extend body! type macro to support () and non-empty tuple arity distinctly
  • Extend rvalue! to build empty tuples (tuple) and update RValueBuilder::tuple
  • InstSimplify: simplify empty tuple aggregates (AggregateKind::Tuple with no operands) to Constant::Unit
  • New test empty_tuple_to_unit(); update inline/pre-inlining snapshot outputs to use () directly in closures/applies
  • Tidy lib.rs feature flags ordering

Written by Cursor Bugbot for commit a01405e. This will update automatically on new commits. Configure here.

Copy link
Member Author

indietyp commented Jan 3, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@augmentcode
Copy link

augmentcode bot commented Jan 3, 2026

🤖 Augment PR Summary

Summary: Canonicalizes empty tuple construction in HashQL MIR and optimizes it into unit (()) constants to reduce redundant aggregates/locals.

Changes:

  • Add `From` for `Operand` so empty-array tuple builders can type-check via `Into<Operand>`.
  • Fix `body!` type macro to handle `()` explicitly and require 1+ elements for non-empty tuple types.
  • Extend `rvalue!` with a `tuple;` form to build empty tuple aggregates.
  • InstSimplify: rewrite empty tuple aggregates (`AggregateKind::Tuple` with no operands) to `Constant::Unit` loads.
  • Add `empty_tuple_to_unit()` coverage and update MIR UI snapshots to reflect the simplified output.
  • Minor tidy: reorder `#![feature(...)]` entries.

Technical Notes: This makes unit values flow as constants earlier, reducing MIR noise and improving downstream pass stability.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.94%. Comparing base (c391344) to head (a01405e).

Files with missing lines Patch % Lines
...shql/mir/src/pass/transform/inst_simplify/tests.rs 94.11% 1 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##           bm/be-197-hashql-implement-inlining    #8237      +/-   ##
=======================================================================
+ Coverage                                64.93%   64.94%   +0.01%     
=======================================================================
  Files                                      735      735              
  Lines                                    62952    62982      +30     
  Branches                                  3676     3677       +1     
=======================================================================
+ Hits                                     40877    40906      +29     
- Misses                                   21596    21597       +1     
  Partials                                   479      479              
Flag Coverage Δ
rust.hashql-compiletest 46.65% <ø> (ø)
rust.hashql-mir 89.69% <96.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 3, 2026

CodSpeed Performance Report

Merging #8237 will not alter performance

Comparing bm/be-270-hashql-simplify-aggregate-to-unit-const (a01405e) with bm/be-197-hashql-implement-inlining (c391344)

Summary

✅ 17 untouched

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

Labels

area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

2 participants