Skip to content

Add arg splat experiment initial tuple impl#153697

Open
teor2345 wants to merge 4 commits intorust-lang:mainfrom
teor2345:fn-arg-splat-experiment
Open

Add arg splat experiment initial tuple impl#153697
teor2345 wants to merge 4 commits intorust-lang:mainfrom
teor2345:fn-arg-splat-experiment

Conversation

@teor2345
Copy link
Copy Markdown
Contributor

@teor2345 teor2345 commented Mar 11, 2026

View all comments

This PR is part of the argument splatting lang experiment, and FFI overloading / C++ interop project goals:

Example code using existing unstable features:

Discussion of implementation strategy:

The PR is the initial implementation of the feature:

  • splat incomplete feature gate
  • #[splat] attribute on function arguments
  • #[splat] function parameter check at THIR level
  • splatted MIR lowering and tupling
  • feature gate and UI tests for item type filtering, non-splattable arguments, splattable tuples, generics, and the "overloading at home" example

Once this PR merges, we can add further functionality, then test it out in interop tools.

Unrelated Changes

  • Fix a comment typo in a UI test
  • Add rust-analyzer target dirs to .gitignore (created by some tests)

TODOs

Out of Scope for this PR

  • Change codegen to de-tuple caller and callee
  • Improve perf of splatting (by decreasing memory usage) by storing only a splatted flag, and looking up the argument index from the span attributes every time

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 11, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 11, 2026

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 16 candidates

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_builtin_macros/src/splat.rs Outdated
@JohnTitor
Copy link
Copy Markdown
Member

It should be better for someone on https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/On.20overloading/with/573924937 to review this, @oli-obk could you take over?

@oli-obk oli-obk assigned oli-obk and unassigned JohnTitor Mar 11, 2026
@oli-obk oli-obk added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Mar 12, 2026
@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Mar 12, 2026

Let's wait for the ongoing discussion on Zulip to figure out whether we need to have a proc macro, an AST manipulating attribute (like define_opaque), or just a normal attribute

@teor2345 teor2345 marked this pull request as draft March 13, 2026 06:49
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 13, 2026
@teor2345 teor2345 force-pushed the fn-arg-splat-experiment branch from 89102bf to c784a57 Compare March 16, 2026 07:35
@rustbot rustbot added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Mar 16, 2026
Comment thread compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs Outdated
Comment thread compiler/rustc_hir/src/target.rs
Comment thread tests/ui/splat/splat-non-function.rs Outdated
@teor2345 teor2345 force-pushed the fn-arg-splat-experiment branch from c784a57 to 2d9e563 Compare March 20, 2026 01:37
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) labels Mar 20, 2026
@teor2345

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

teor2345

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Mar 20, 2026
@rust-log-analyzer

This comment has been minimized.

@teor2345 teor2345 force-pushed the fn-arg-splat-experiment branch from 2301895 to f242558 Compare April 22, 2026 07:05
@teor2345 teor2345 marked this pull request as ready for review April 22, 2026 07:08
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 22, 2026
@Zalathar
Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 22, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Apr 22, 2026
Add arg splat experiment initial tuple impl
@rust-log-analyzer

This comment has been minimized.

@teor2345 teor2345 force-pushed the fn-arg-splat-experiment branch from f242558 to f5c600e Compare April 22, 2026 08:11
@rust-log-analyzer

This comment has been minimized.

@teor2345 teor2345 force-pushed the fn-arg-splat-experiment branch from f5c600e to 2d85a32 Compare April 22, 2026 09:30
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 22, 2026

☀️ Try build successful (CI)
Build commit: 09bdcac (09bdcacc122783c42bf339f270461b2a461748b7, parent: 1bfcb284f7a2199ad322daa463e29e708d5bc635)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (09bdcac): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 2
Regressions ❌
(secondary)
0.4% [0.1%, 1.1%] 13
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 2

Max RSS (memory usage)

Results (secondary 4.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.8% [4.2%, 5.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary -2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.6% [3.6%, 3.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-6.0%, -3.4%] 2
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 77
Regressions ❌
(secondary)
0.2% [0.0%, 0.7%] 57
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 77

Bootstrap: 491.717s -> 491.643s (-0.02%)
Artifact size: 394.44 MiB -> 394.50 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 22, 2026
@teor2345
Copy link
Copy Markdown
Contributor Author

teor2345 commented Apr 22, 2026

Edit: the regressions are in nalgebra, image, the CTFE stress tests, and wg-grammar. They reverse 30-60% of the gain from #155223, but only for those specific benchmarks. The only benchmark that's worse overall is the secondary CTFE stress test.

As expected, adding a 2 byte splatted argument index to FnDecl and FnSig partly reverses some of the performance gains from removing 2 or 3 bytes from them here: #155223 (comment)

It might be possible to keep the performance gains by storing just one bit for "an argument is splatted", and looking up the actual argument only when needed.

Are there side-tables that can be used for FnDecl and FnSig?

There's also a more cursed version, which stores one byte for "a low index argument is splatted", and has a marker value for "look up the splatted argument index". (We'd need to test splatted functions with 254-257 arguments, so I'd prefer not to do that unless absolutely needed.)

Comment thread compiler/rustc_ast/src/ast.rs Outdated
Comment thread compiler/rustc_ast_lowering/src/lib.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/check/entry.rs Outdated
Comment thread compiler/rustc_mir_build/src/builder/mod.rs Outdated
Comment thread src/tools/rust-analyzer/crates/hir-ty/src/infer/callee.rs Outdated
@teor2345 teor2345 force-pushed the fn-arg-splat-experiment branch from 2d85a32 to 930eb7a Compare April 23, 2026 07:47
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 2026

Some changes occurred in coverage tests.

cc @Zalathar

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) perf-regression Performance regression. S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants