Skip to content

Fix ICE in label_fn_like for splatted args and add UI tests#157434

Draft
Ajay-singh1 wants to merge 13 commits into
rust-lang:mainfrom
Ajay-singh1:pr-153697
Draft

Fix ICE in label_fn_like for splatted args and add UI tests#157434
Ajay-singh1 wants to merge 13 commits into
rust-lang:mainfrom
Ajay-singh1:pr-153697

Conversation

@Ajay-singh1
Copy link
Copy Markdown
Contributor

@Ajay-singh1 Ajay-singh1 commented Jun 4, 2026

This PR builds on top of #153697 (teor's #[splat] implementation).

Bug Fix

While writing UI tests for the unhappy path of the overload-at-home example, I discovered an ICE when calling a splatted function with an argument combination that has no registered impl:

foo.method(42i32, 42i32); // no impl for (i32, i32)
// ICE: arg index 1 out of bounds for method with 1 inputs

The condition !tuple_arguments.is_splatted() in label_fn_like was inverted , the safe use_splat_fallback path ran for non-splatted functions, and the span_bug! fired for splatted ones. Fix is removing the !.

After the fix the compiler gives a clean error instead:

error[E0308]: mismatched types expected String, found i32

CC: @teor2345

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 4, 2026

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

HIR ty lowering was modified

cc @fmease

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

The reflection data structures are tied exactly to the implementation
in the compiler. Make sure to also adjust rustc_const_eval/src/const_eval/type_info.rs

cc @oli-obk

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

The Miri subtree was changed

cc @rust-lang/miri

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a, @makai410

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

The Cranelift subtree was changed

cc @bjorn3

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Jun 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 4, 2026

Failed to set assignee to teor2345: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@RalfJung
Copy link
Copy Markdown
Member

RalfJung commented Jun 4, 2026

I'd recommend opening such PRs as a draft until they are ready for review. That avoids pinging everyone. :)

@Ajay-singh1 Ajay-singh1 marked this pull request as draft June 4, 2026 13:41
@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 Jun 4, 2026
Copy link
Copy Markdown
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks good, just a few tweaks to improve the test coverage. Feel free to edit your existing commits and force-push, or add fixup commits.

(Normally we use fixup commits to make reviews easier when there are rebases, then squash when the PR is ready. But in this case it doesn't matter.)

View changes since this review

@@ -0,0 +1,31 @@
// tests/ui/splat/splat-generics-inside-tuple.rs
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.

This test looks good, but no need to repeat the file path at the top of the file. The comment describing the purpose of the test is enough.

(This comment applies to each test file.)

Suggested change
// tests/ui/splat/splat-generics-inside-tuple.rs


impl FooTrait for Foo {
fn method(#[splat] _: (u32, f32)) {}
//~^ ERROR
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.

Please add part of the error text here (and below), so we know if we accidentally change the error type

Suggested change
//~^ ERROR
//~^ ERROR method `method` has an incompatible type for trait

@teor2345
Copy link
Copy Markdown
Contributor

teor2345 commented Jun 4, 2026

r? teor2345

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

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. 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.

4 participants