Fix splat ICEs and ban it in closures#158645
Conversation
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| (*fn_ptr)(1u32, 2i8); | ||
| let fn_pp: *const fn(#[splat] (u32, i8)) = tuple_args as *const fn(#[splat] (u32, i8)); | ||
| (*fn_pp)(1, 2); | ||
| (*fn_pp)(1u32, 2i8); |
There was a problem hiding this comment.
I'd expect this to need unsafe, you are reading from a raw pointer.
| } | ||
|
|
||
| if !splatted_arg_indexes.is_empty() { | ||
| if let SplatSemantic::NoClosures(closure_span) = splat_semantic { |
There was a problem hiding this comment.
why is this not a match (together with the other if let below)?
| Extern::Explicit(abi_str, span) | ||
| if abi_str.symbol_unescaped.as_str() == "rust-call" => | ||
| { | ||
| SplatSemantic::NoRustCall(span) | ||
| } | ||
| Extern::Explicit(_abi_str, _span) => SplatSemantic::Yes, |
There was a problem hiding this comment.
| Extern::Explicit(abi_str, span) | |
| if abi_str.symbol_unescaped.as_str() == "rust-call" => | |
| { | |
| SplatSemantic::NoRustCall(span) | |
| } | |
| Extern::Explicit(_abi_str, _span) => SplatSemantic::Yes, | |
| Extern::Explicit(abi_str, span) => match abi_str.symbol_unescaped { | |
| sym::rust_dash_call => SplatSemantic::NoRustCall(span), | |
| _ => SplatSemantic::Yes, | |
| }, |
There was a problem hiding this comment.
and add a comment on why here too perhaps?
| // FIXME(splat): should splatting extern "C" fns be allowed? | ||
| Extern::Implicit(_) => SplatSemantic::Yes, |
There was a problem hiding this comment.
well extern "C" probably yes? but for most other extern "CC"s probably not actually? Anyhow, not for this PR.
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
| LL | dyn_asref_splat(&s); | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error[E0277]: cannot use splat attribute; the splatted argument type must be a tuple or unit, not a Trait(std::convert::AsRef<(u8 |
There was a problem hiding this comment.
The tuple case (AsRef<(u8, f32)>) renders truncated Trait(std::convert::AsRef<(u8 with no closing , f32)>). Is this expected, or a bug in how the diagnostic formats tuple types?
|
The job Click to see the possible cause of the failure (guessed by this bot) |
This PR is part of the splat lang experiment #153629.
It fixes one ICE, and cleans up the surrounding error handling to avoid future ICEs:
Close #158482
Improves the message and error handling in another ICE (but doesn't fix it):
cc #158603
And bans splat on closures and rust-call, because they already de-tuple arguments:
Close #158605
In the process I discovered another symbol mangling bug with splatting, which I added a test for (but didn't fix yet):
cc #158644
This test might be flaky, I'll drop it from this PR if it fails in CI.