Skip to content

Commit 53a5900

Browse files
committed
Don't warn about v128 in wasm ABI transition
This has other warnings if necessary and doesn't need extra warnings from this FCW. cc #138762
1 parent 6a0bd27 commit 53a5900

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool
9999
return true;
100100
}
101101

102+
// If this is a simd argument let other rustc warnings kick in and don't
103+
// provide extra warnings here
104+
if uses_vector_registers(&arg.mode, &arg.layout.backend_repr) {
105+
return true;
106+
}
107+
102108
// This matches `unwrap_trivial_aggregate` in the wasm ABI logic.
103109
if arg.layout.is_aggregate() {
104110
let cx = LayoutCx::new(tcx, TypingEnv::fully_monomorphized());

tests/ui/lint/wasm_c_abi_transition.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@ add-core-stubs
44
//@ build-fail
55

6-
#![feature(no_core)]
6+
#![feature(no_core, repr_simd)]
77
#![no_core]
88
#![crate_type = "lib"]
99
#![deny(wasm_c_abi)]
@@ -45,3 +45,16 @@ pub fn call_other_fun(x: MyType) {
4545
pub struct MyZstType;
4646
#[allow(improper_ctypes_definitions)]
4747
pub extern "C" fn zst_safe(_x: (), _y: MyZstType) {}
48+
49+
// The `v128` is already warned as not-FFI-safe by the
50+
// `improper_ctypes_definitions` lint, so no need to doubly warn about it with
51+
// the `wasm_c_abi` lint. Test for the lint from `improper_ctypes_definitions`
52+
// but this doubly asserts that there are no other lints, such as from the
53+
// `wasm_c_abi` lint.
54+
#[repr(simd)]
55+
#[allow(non_camel_case_types)]
56+
pub struct v128([i32; 4]);
57+
#[target_feature(enable = "simd128")]
58+
pub extern "C" fn my_safe_simd(x: v128) -> v128 { x }
59+
//~^ WARN `extern` fn uses type `v128`, which is not FFI-safe
60+
//~| WARN `extern` fn uses type `v128`, which is not FFI-safe

tests/ui/lint/wasm_c_abi_transition.stderr

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
warning: `extern` fn uses type `v128`, which is not FFI-safe
2+
--> $DIR/wasm_c_abi_transition.rs:58:35
3+
|
4+
LL | pub extern "C" fn my_safe_simd(x: v128) -> v128 { x }
5+
| ^^^^ not FFI-safe
6+
|
7+
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
8+
= note: this struct has unspecified layout
9+
note: the type is defined here
10+
--> $DIR/wasm_c_abi_transition.rs:56:1
11+
|
12+
LL | pub struct v128([i32; 4]);
13+
| ^^^^^^^^^^^^^^^
14+
= note: `#[warn(improper_ctypes_definitions)]` on by default
15+
16+
warning: `extern` fn uses type `v128`, which is not FFI-safe
17+
--> $DIR/wasm_c_abi_transition.rs:58:44
18+
|
19+
LL | pub extern "C" fn my_safe_simd(x: v128) -> v128 { x }
20+
| ^^^^ not FFI-safe
21+
|
22+
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
23+
= note: this struct has unspecified layout
24+
note: the type is defined here
25+
--> $DIR/wasm_c_abi_transition.rs:56:1
26+
|
27+
LL | pub struct v128([i32; 4]);
28+
| ^^^^^^^^^^^^^^^
29+
130
error: this function definition involves an argument of type `MyType` which is affected by the wasm ABI transition
231
--> $DIR/wasm_c_abi_transition.rs:18:1
332
|
@@ -33,7 +62,7 @@ LL | unsafe { other_fun(x) }
3362
= note: for more information, see issue #138762 <https://github.com/rust-lang/rust/issues/138762>
3463
= help: the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target
3564

36-
error: aborting due to 3 previous errors
65+
error: aborting due to 3 previous errors; 2 warnings emitted
3766

3867
Future incompatibility report: Future breakage diagnostic:
3968
error: this function definition involves an argument of type `MyType` which is affected by the wasm ABI transition

0 commit comments

Comments
 (0)