diff options
| -rw-r--r-- | tests/ui/abi/unsupported-in-impls.rs | 33 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported-in-impls.stderr | 27 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.aarch64.stderr | 26 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.arm.stderr | 26 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.riscv32.stderr | 26 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.riscv64.stderr | 26 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.rs | 24 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.x64.stderr | 26 | ||||
| -rw-r--r-- | tests/ui/abi/unsupported.x64_win.stderr | 26 |
9 files changed, 66 insertions, 174 deletions
diff --git a/tests/ui/abi/unsupported-in-impls.rs b/tests/ui/abi/unsupported-in-impls.rs new file mode 100644 index 00000000000..65a79e7643c --- /dev/null +++ b/tests/ui/abi/unsupported-in-impls.rs @@ -0,0 +1,33 @@ +// Test for https://github.com/rust-lang/rust/issues/86232 +// Due to AST-to-HIR lowering nuances, we used to allow unsupported ABIs to "leak" into the HIR +// without being checked, as we would check after generating the ExternAbi. +// +// Here we test that an unsupported ABI in various impl-related positions will be rejected, +// both in the original declarations and the actual implementations. + +#![feature(rustc_attrs)] +//@ compile-flags: --crate-type lib + +pub struct FnPtrBearer { + pub ptr: extern "rust-invalid" fn(), + //~^ ERROR: is not a supported ABI +} + +impl FnPtrBearer { + pub extern "rust-invalid" fn inherent_fn(self) { + //~^ ERROR: is not a supported ABI + (self.ptr)() + } +} + +pub trait Trait { + extern "rust-invalid" fn trait_fn(self); + //~^ ERROR: is not a supported ABI +} + +impl Trait for FnPtrBearer { + extern "rust-invalid" fn trait_fn(self) { + //~^ ERROR: is not a supported ABI + self.inherent_fn() + } +} diff --git a/tests/ui/abi/unsupported-in-impls.stderr b/tests/ui/abi/unsupported-in-impls.stderr new file mode 100644 index 00000000000..d7a188f8a04 --- /dev/null +++ b/tests/ui/abi/unsupported-in-impls.stderr @@ -0,0 +1,27 @@ +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:15:21 + | +LL | pub ptr: extern "rust-invalid" fn(), + | ^^^^^^^^^^^^^^ + +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:20:16 + | +LL | pub extern "rust-invalid" fn inherent_fn(self) { + | ^^^^^^^^^^^^^^ + +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:27:12 + | +LL | extern "rust-invalid" fn trait_fn(self); + | ^^^^^^^^^^^^^^ + +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:32:12 + | +LL | extern "rust-invalid" fn trait_fn(self) { + | ^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.aarch64.stderr b/tests/ui/abi/unsupported.aarch64.stderr index 85e251a65d2..b89f7359b3f 100644 --- a/tests/ui/abi/unsupported.aarch64.stderr +++ b/tests/ui/abi/unsupported.aarch64.stderr @@ -156,30 +156,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:141:17 - | -LL | ptr: extern "thiscall" fn(), - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:146:16 - | -LL | pub extern "thiscall" fn inherent_fn(self) { - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:153:12 - | -LL | extern "thiscall" fn trait_fn(self); - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:158:12 - | -LL | extern "thiscall" fn trait_fn(self) { - | ^^^^^^^^^^ - warning: "cdecl" is not a supported ABI for the current target --> $DIR/unsupported.rs:99:17 | @@ -221,6 +197,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error: aborting due to 29 previous errors; 4 warnings emitted +error: aborting due to 25 previous errors; 4 warnings emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.arm.stderr b/tests/ui/abi/unsupported.arm.stderr index a4274d0ac60..173cbf9715b 100644 --- a/tests/ui/abi/unsupported.arm.stderr +++ b/tests/ui/abi/unsupported.arm.stderr @@ -138,30 +138,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:141:17 - | -LL | ptr: extern "thiscall" fn(), - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:146:16 - | -LL | pub extern "thiscall" fn inherent_fn(self) { - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:153:12 - | -LL | extern "thiscall" fn trait_fn(self); - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:158:12 - | -LL | extern "thiscall" fn trait_fn(self) { - | ^^^^^^^^^^ - warning: "cdecl" is not a supported ABI for the current target --> $DIR/unsupported.rs:99:17 | @@ -203,6 +179,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error: aborting due to 26 previous errors; 4 warnings emitted +error: aborting due to 22 previous errors; 4 warnings emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.riscv32.stderr b/tests/ui/abi/unsupported.riscv32.stderr index 7ef7cae5057..cb9b758a730 100644 --- a/tests/ui/abi/unsupported.riscv32.stderr +++ b/tests/ui/abi/unsupported.riscv32.stderr @@ -150,30 +150,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:141:17 - | -LL | ptr: extern "thiscall" fn(), - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:146:16 - | -LL | pub extern "thiscall" fn inherent_fn(self) { - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:153:12 - | -LL | extern "thiscall" fn trait_fn(self); - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:158:12 - | -LL | extern "thiscall" fn trait_fn(self) { - | ^^^^^^^^^^ - warning: "cdecl" is not a supported ABI for the current target --> $DIR/unsupported.rs:99:17 | @@ -215,6 +191,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error: aborting due to 28 previous errors; 4 warnings emitted +error: aborting due to 24 previous errors; 4 warnings emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.riscv64.stderr b/tests/ui/abi/unsupported.riscv64.stderr index 7ef7cae5057..cb9b758a730 100644 --- a/tests/ui/abi/unsupported.riscv64.stderr +++ b/tests/ui/abi/unsupported.riscv64.stderr @@ -150,30 +150,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:141:17 - | -LL | ptr: extern "thiscall" fn(), - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:146:16 - | -LL | pub extern "thiscall" fn inherent_fn(self) { - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:153:12 - | -LL | extern "thiscall" fn trait_fn(self); - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:158:12 - | -LL | extern "thiscall" fn trait_fn(self) { - | ^^^^^^^^^^ - warning: "cdecl" is not a supported ABI for the current target --> $DIR/unsupported.rs:99:17 | @@ -215,6 +191,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error: aborting due to 28 previous errors; 4 warnings emitted +error: aborting due to 24 previous errors; 4 warnings emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.rs b/tests/ui/abi/unsupported.rs index 4bb732c94ac..0ee310676ba 100644 --- a/tests/ui/abi/unsupported.rs +++ b/tests/ui/abi/unsupported.rs @@ -136,27 +136,3 @@ extern "C-cmse-nonsecure-entry" {} extern "cdecl" {} //[x64_win]~^ WARN unsupported_calling_conventions //[x64_win]~^^ WARN this was previously accepted - -struct FnPtrBearer { - ptr: extern "thiscall" fn(), - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI -} - -impl FnPtrBearer { - pub extern "thiscall" fn inherent_fn(self) { - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI - (self.ptr)() - } -} - -trait Trait { - extern "thiscall" fn trait_fn(self); - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI -} - -impl Trait for FnPtrBearer { - extern "thiscall" fn trait_fn(self) { - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR: is not a supported ABI - self.inherent_fn() - } -} diff --git a/tests/ui/abi/unsupported.x64.stderr b/tests/ui/abi/unsupported.x64.stderr index 7b021dff7c9..1a7b01375cf 100644 --- a/tests/ui/abi/unsupported.x64.stderr +++ b/tests/ui/abi/unsupported.x64.stderr @@ -132,30 +132,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:141:17 - | -LL | ptr: extern "thiscall" fn(), - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:146:16 - | -LL | pub extern "thiscall" fn inherent_fn(self) { - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:153:12 - | -LL | extern "thiscall" fn trait_fn(self); - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:158:12 - | -LL | extern "thiscall" fn trait_fn(self) { - | ^^^^^^^^^^ - warning: "cdecl" is not a supported ABI for the current target --> $DIR/unsupported.rs:99:17 | @@ -197,6 +173,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error: aborting due to 25 previous errors; 4 warnings emitted +error: aborting due to 21 previous errors; 4 warnings emitted For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.x64_win.stderr b/tests/ui/abi/unsupported.x64_win.stderr index 4ce5b3340d1..82b64e45b01 100644 --- a/tests/ui/abi/unsupported.x64_win.stderr +++ b/tests/ui/abi/unsupported.x64_win.stderr @@ -100,30 +100,6 @@ error[E0570]: "C-cmse-nonsecure-entry" is not a supported ABI for the current ta LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:141:17 - | -LL | ptr: extern "thiscall" fn(), - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:146:16 - | -LL | pub extern "thiscall" fn inherent_fn(self) { - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:153:12 - | -LL | extern "thiscall" fn trait_fn(self); - | ^^^^^^^^^^ - -error[E0570]: "thiscall" is not a supported ABI for the current target - --> $DIR/unsupported.rs:158:12 - | -LL | extern "thiscall" fn trait_fn(self) { - | ^^^^^^^^^^ - warning: "stdcall" is not a supported ABI for the current target --> $DIR/unsupported.rs:81:19 | @@ -215,6 +191,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error: aborting due to 21 previous errors; 9 warnings emitted +error: aborting due to 17 previous errors; 9 warnings emitted For more information about this error, try `rustc --explain E0570`. |
