Skip to content

Avoid underflow for splatted rust-call receivers#158850

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-158800-splat-self-wfcheck-overflow
Jul 19, 2026
Merged

Avoid underflow for splatted rust-call receivers#158850
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
chenyukang:yukang-fix-158800-splat-self-wfcheck-overflow

Conversation

@chenyukang

@chenyukang chenyukang commented Jul 6, 2026

Copy link
Copy Markdown
Member

Fixes #158800

We alreay have proper error for #[splat] self in following code, so here we just need to avoid the overflow.

cc @teor2345

@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. labels Jul 6, 2026
@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 75 candidates
  • Random selection from 20 candidates

@jieyouxu jieyouxu added the F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 label Jul 6, 2026

@teor2345 teor2345 left a comment

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.

I think that banning splat on rust-call and closures in PR #158645 will make these fixes obsolete. But there's still some useful changes we can make in this code.

View changes since this review

Comment thread tests/ui/splat/splat-self-rust-call-issue-158800.rs
@@ -1717,14 +1717,18 @@ fn check_fn_or_method<'tcx>(
let has_implicit_self = hir_decl.implicit_self().has_implicit_self();
let mut inputs = sig.inputs().iter().skip(if has_implicit_self { 1 } else { 0 });
// FIXME(splat): support the rest of closure splatting, or replace this code with an 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.

Based on the ban in #158645, this splatted closure code should probably become a compiler error (or an ICE bug).

And we can delete the rest of the calculations, so there's no underflow.

@teor2345

teor2345 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Oh, and thank you for the PR! It's great to have a bunch of people finding bugs and fixing things.

@chenyukang

chenyukang commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

I think that banning splat on rust-call and closures in PR #158645 will make these fixes obsolete. But there's still some useful changes we can make in this code.

View changes since this review

I will rework on it after #158645 is merged.

@teor2345

teor2345 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@rustbot author

@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 Jul 6, 2026
@teor2345

Copy link
Copy Markdown
Contributor

I will rework on it after #158645 is merged.

It has been merged 🙂

@chenyukang
chenyukang force-pushed the yukang-fix-158800-splat-self-wfcheck-overflow branch from ca4c42e to 90933f3 Compare July 16, 2026 02:27
@rustbot

This comment has been minimized.

@chenyukang

chenyukang commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

I will rework on it after #158645 is merged.

It has been merged 🙂

I have a test after rebasing on main branch.

there will be an extra error message:

error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI
  --> /tmp/ha.rs:12:5
   |
12 |     extern "rust-call" fn call_once(#[splat] self) {}
   |     ^^^^^^^^^^^^^^^^^^              ^^^^^^^^
   |
   = help: remove `#[splat]` or change the ABI

but the ICE will happen without the patch on https://github.com/chenyukang/rust/blob/90933f34fd6570c7b82e9e4a464513e9cd99d591/compiler/rustc_hir_analysis/src/check/wfcheck.rs#L1652-L1671.

you assume the code will not run into this part after #158645?

@teor2345

Copy link
Copy Markdown
Contributor

you assume the code will not run into this part after #158645?

We should add a test that exercises that code, if it runs we must fix the ICE. If we can't make it run using a test, then it's up to you if you want to fix or delete the code. Usually we would delete code for things that are rejected in earlier stages.

@chenyukang
chenyukang force-pushed the yukang-fix-158800-splat-self-wfcheck-overflow branch from 90933f3 to d1f8053 Compare July 16, 2026 10:25
@chenyukang

Copy link
Copy Markdown
Member Author

you assume the code will not run into this part after #158645?

We should add a test that exercises that code, if it runs we must fix the ICE. If we can't make it run using a test, then it's up to you if you want to fix or delete the code. Usually we would delete code for things that are rejected in earlier stages.

aha, got it.
it's better to remove this part, I already updated the code.

@teor2345 teor2345 left a comment

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.

Thanks for the extra test, this looks good!

View changes since this review

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks
@bors r=teor2345,jieyouxu rollup

View changes since this review

Comment thread tests/ui/splat/splat-self-rust-call-issue-158800.rs Outdated
@rust-bors

This comment was marked as outdated.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2026
@rust-lang rust-lang deleted a comment from rust-bors Bot Jul 19, 2026
@jieyouxu

Copy link
Copy Markdown
Member

r= me and teor with the nit
@bors r-

@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 19, 2026
@rust-bors

This comment was marked as off-topic.

@chenyukang
chenyukang force-pushed the yukang-fix-158800-splat-self-wfcheck-overflow branch from d1f8053 to c213b5f Compare July 19, 2026 11:50
@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@chenyukang

Copy link
Copy Markdown
Member Author

@bors r=teor2345,jieyouxu

@rust-bors

rust-bors Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c213b5f has been approved by teor2345,jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 19, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #159524 (Gather PGO profiles in parallel)
 - #158850 (Avoid underflow for splatted rust-call receivers)
 - #159215 ([compiletest] Differentiate between LLVM LLDB and Apple LLDB)
 - #159347 (Document rustc_public lib.rs and update README)
 - #159469 (Reorganize `tests/ui/issues` [27/N])
 - #159512 (Add regression tests for fixed dead-code issues)
@rust-bors
rust-bors Bot merged commit d385755 into rust-lang:main Jul 19, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 19, 2026
rust-timer added a commit that referenced this pull request Jul 19, 2026
Rollup merge of #158850 - chenyukang:yukang-fix-158800-splat-self-wfcheck-overflow, r=teor2345,jieyouxu

Avoid underflow for splatted rust-call receivers

Fixes #158800

We alreay have proper error for `#[splat] self` in following code, so here we just need to avoid the overflow.

cc @teor2345
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 22, 2026
…nTitor

Add more splat rust-call regression tests

Tracking issue: rust-lang#153629

This PR provides more test coverage for splat, rust-call, and closure rejection (bugs rust-lang#158800 and rust-lang#158605), after the fixes in PRs rust-lang#158645 and rust-lang#158850.

This PR only contains tests.

@rustbot +F-splat +T-compiler +C-bug
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 22, 2026
…nTitor

Add more splat rust-call regression tests

Tracking issue: rust-lang#153629

This PR provides more test coverage for splat, rust-call, and closure rejection (bugs rust-lang#158800 and rust-lang#158605), after the fixes in PRs rust-lang#158645 and rust-lang#158850.

This PR only contains tests.

@rustbot +F-splat +T-compiler +C-bug
rust-timer added a commit that referenced this pull request Jul 22, 2026
Rollup merge of #159629 - teor2345:splat-closure-test, r=JohnTitor

Add more splat rust-call regression tests

Tracking issue: #153629

This PR provides more test coverage for splat, rust-call, and closure rejection (bugs #158800 and #158605), after the fixes in PRs #158645 and #158850.

This PR only contains tests.

@rustbot +F-splat +T-compiler +C-bug
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 22, 2026
Add more splat rust-call regression tests

Tracking issue: rust-lang/rust#153629

This PR provides more test coverage for splat, rust-call, and closure rejection (bugs rust-lang/rust#158800 and rust-lang/rust#158605), after the fixes in PRs rust-lang/rust#158645 and rust-lang/rust#158850.

This PR only contains tests.

@rustbot +F-splat +T-compiler +C-bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

[ICE]: attempt to subtract with overflow

4 participants