diff --git a/tests/ui/splat/splat-rust-call-fn-trait-issue-158800.rs b/tests/ui/splat/splat-rust-call-fn-trait-issue-158800.rs new file mode 100644 index 0000000000000..dc207530cba49 --- /dev/null +++ b/tests/ui/splat/splat-rust-call-fn-trait-issue-158800.rs @@ -0,0 +1,14 @@ +//! Regression test for `#[splat] ()` in a rust-call Fn* trait method not ICEing in WF +//! checking. + +#![feature(splat)] +#![feature(unboxed_closures)] +#![expect(incomplete_features)] + +impl dyn FnOnce(T) -> () { + //~^ ERROR cannot define inherent `impl` for a type outside of the crate + extern "rust-call" fn call_once(#[splat] _: ()) {} + //~^ ERROR `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI +} + +fn main() {} diff --git a/tests/ui/splat/splat-rust-call-fn-trait-issue-158800.stderr b/tests/ui/splat/splat-rust-call-fn-trait-issue-158800.stderr new file mode 100644 index 0000000000000..e20b21863fd90 --- /dev/null +++ b/tests/ui/splat/splat-rust-call-fn-trait-issue-158800.stderr @@ -0,0 +1,20 @@ +error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + --> $DIR/splat-rust-call-fn-trait-issue-158800.rs:10:5 + | +LL | extern "rust-call" fn call_once(#[splat] _: ()) {} + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ + | + = help: remove `#[splat]` or change the ABI + +error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined + --> $DIR/splat-rust-call-fn-trait-issue-158800.rs:8:1 + | +LL | impl dyn FnOnce(T) -> () { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate + | + = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it + = note: for more details about the orphan rules, see + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0116`. diff --git a/tests/ui/splat/splat-self-rust-call-issue-158800.rs b/tests/ui/splat/splat-rust-call-fn-trait-self-issue-158800.rs similarity index 81% rename from tests/ui/splat/splat-self-rust-call-issue-158800.rs rename to tests/ui/splat/splat-rust-call-fn-trait-self-issue-158800.rs index 1dac2cf0fe4d1..c4c66c4ace718 100644 --- a/tests/ui/splat/splat-self-rust-call-issue-158800.rs +++ b/tests/ui/splat/splat-rust-call-fn-trait-self-issue-158800.rs @@ -1,9 +1,9 @@ -//! Regression test for `#[splat] self` in a rust-call method not ICEing in WF +//! Regression test for `#[splat] self` in a rust-call Fn* trait method not ICEing in WF //! checking. #![feature(splat)] #![feature(unboxed_closures)] -#![allow(incomplete_features)] +#![expect(incomplete_features)] impl dyn FnOnce(T) -> () { //~^ ERROR cannot define inherent `impl` for a type outside of the crate diff --git a/tests/ui/splat/splat-self-rust-call-issue-158800.stderr b/tests/ui/splat/splat-rust-call-fn-trait-self-issue-158800.stderr similarity index 87% rename from tests/ui/splat/splat-self-rust-call-issue-158800.stderr rename to tests/ui/splat/splat-rust-call-fn-trait-self-issue-158800.stderr index 4ddf43b9843b2..41f1f211e3125 100644 --- a/tests/ui/splat/splat-self-rust-call-issue-158800.stderr +++ b/tests/ui/splat/splat-rust-call-fn-trait-self-issue-158800.stderr @@ -1,5 +1,5 @@ error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI - --> $DIR/splat-self-rust-call-issue-158800.rs:10:5 + --> $DIR/splat-rust-call-fn-trait-self-issue-158800.rs:10:5 | LL | extern "rust-call" fn call_once(#[splat] self) {} | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ @@ -7,13 +7,13 @@ LL | extern "rust-call" fn call_once(#[splat] self) {} = help: remove `#[splat]` or change the ABI error: functions with the "rust-call" ABI must take a single non-self tuple argument - --> $DIR/splat-self-rust-call-issue-158800.rs:10:46 + --> $DIR/splat-rust-call-fn-trait-self-issue-158800.rs:10:46 | LL | extern "rust-call" fn call_once(#[splat] self) {} | ^^^^ error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined - --> $DIR/splat-self-rust-call-issue-158800.rs:8:1 + --> $DIR/splat-rust-call-fn-trait-self-issue-158800.rs:8:1 | LL | impl dyn FnOnce(T) -> () { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl for type defined outside of crate @@ -22,7 +22,7 @@ LL | impl dyn FnOnce(T) -> () { = note: for more details about the orphan rules, see error[E0277]: the size for values of type `(dyn FnOnce(T) + 'static)` cannot be known at compilation time - --> $DIR/splat-self-rust-call-issue-158800.rs:10:46 + --> $DIR/splat-rust-call-fn-trait-self-issue-158800.rs:10:46 | LL | extern "rust-call" fn call_once(#[splat] self) {} | ^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/splat/splat-rust-call-trait-issue-158800.rs b/tests/ui/splat/splat-rust-call-trait-issue-158800.rs new file mode 100644 index 0000000000000..188575e97793f --- /dev/null +++ b/tests/ui/splat/splat-rust-call-trait-issue-158800.rs @@ -0,0 +1,19 @@ +//! Regression test for `#[splat] ()` in a rust-call trait method not ICEing in WF +//! checking. + +#![feature(splat)] +#![feature(unboxed_closures)] +#![expect(incomplete_features)] + +trait Trait { + extern "rust-call" fn f(#[splat] _: ()) where Self: Sized; + //~^ ERROR `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI +} + +impl dyn Trait { + extern "rust-call" fn f(#[splat] _: ()) where Self: Sized {} + //~^ ERROR `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + //~| ERROR the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time +} + +fn main() {} diff --git a/tests/ui/splat/splat-rust-call-trait-issue-158800.stderr b/tests/ui/splat/splat-rust-call-trait-issue-158800.stderr new file mode 100644 index 0000000000000..4614be97ea0b4 --- /dev/null +++ b/tests/ui/splat/splat-rust-call-trait-issue-158800.stderr @@ -0,0 +1,31 @@ +error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + --> $DIR/splat-rust-call-trait-issue-158800.rs:9:5 + | +LL | extern "rust-call" fn f(#[splat] _: ()) where Self: Sized; + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ + | + = help: remove `#[splat]` or change the ABI + +error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + --> $DIR/splat-rust-call-trait-issue-158800.rs:14:5 + | +LL | extern "rust-call" fn f(#[splat] _: ()) where Self: Sized {} + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ + | + = help: remove `#[splat]` or change the ABI + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/splat-rust-call-trait-issue-158800.rs:14:51 + | +LL | extern "rust-call" fn f(#[splat] _: ()) where Self: Sized {} + | ^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/splat/splat-rust-call-type-issue-158800.rs b/tests/ui/splat/splat-rust-call-type-issue-158800.rs new file mode 100644 index 0000000000000..286ee7410117b --- /dev/null +++ b/tests/ui/splat/splat-rust-call-type-issue-158800.rs @@ -0,0 +1,25 @@ +//! Regression test for `#[splat] ())` in a rust-call type method not ICEing in WF +//! checking. + +#![feature(splat)] +#![feature(unboxed_closures)] +#![expect(incomplete_features)] + +struct Type; + +trait Trait { + extern "rust-call" fn f(#[splat] _: ()); + //~^ ERROR `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI +} + +impl Type { + extern "rust-call" fn f2(#[splat] _: ()) {} + //~^ ERROR `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI +} + +impl Trait for Type { + extern "rust-call" fn f(#[splat] _: ()) {} + //~^ ERROR `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI +} + +fn main() {} diff --git a/tests/ui/splat/splat-rust-call-type-issue-158800.stderr b/tests/ui/splat/splat-rust-call-type-issue-158800.stderr new file mode 100644 index 0000000000000..df0d4f7a3c7b5 --- /dev/null +++ b/tests/ui/splat/splat-rust-call-type-issue-158800.stderr @@ -0,0 +1,26 @@ +error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + --> $DIR/splat-rust-call-type-issue-158800.rs:11:5 + | +LL | extern "rust-call" fn f(#[splat] _: ()); + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ + | + = help: remove `#[splat]` or change the ABI + +error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + --> $DIR/splat-rust-call-type-issue-158800.rs:16:5 + | +LL | extern "rust-call" fn f2(#[splat] _: ()) {} + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ + | + = help: remove `#[splat]` or change the ABI + +error: `#[splat]` is not allowed in the arguments of functions with the `rust-call` ABI + --> $DIR/splat-rust-call-type-issue-158800.rs:21:5 + | +LL | extern "rust-call" fn f(#[splat] _: ()) {} + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^ + | + = help: remove `#[splat]` or change the ABI + +error: aborting due to 3 previous errors +