Avoid underflow for splatted rust-call receivers#158850
Conversation
|
r? @jieyouxu rustbot has assigned @jieyouxu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
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.
| @@ -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 | |||
There was a problem hiding this comment.
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.
|
Oh, and thank you for the PR! It's great to have a bunch of people finding bugs and fixing things. |
|
@rustbot author |
It has been merged 🙂 |
ca4c42e to
90933f3
Compare
This comment has been minimized.
This comment has been minimized.
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 ABIbut 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? |
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. |
90933f3 to
d1f8053
Compare
aha, got it. |
This comment was marked as outdated.
This comment was marked as outdated.
|
r= me and teor with the nit |
This comment was marked as off-topic.
This comment was marked as off-topic.
d1f8053 to
c213b5f
Compare
|
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. |
|
@bors r=teor2345,jieyouxu |
…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)
…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
…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
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
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
Fixes #158800
We alreay have proper error for
#[splat] selfin following code, so here we just need to avoid the overflow.cc @teor2345