Skip to content

Commit 88d8fd2

Browse files
committed
Ignore zero-sized types in wasm future-compat warning
This commit fixes a false positive of the warning triggered for #138762 and the fix is to codify that zero-sized types are "safe" in both the old and new ABIs.
1 parent e0883a2 commit 88d8fd2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool
111111
}
112112
}
113113

114+
// Zero-sized types are dropped in both ABIs, so they're safe
115+
if arg.layout.size.bytes() == 0 {
116+
return true;
117+
}
118+
114119
false
115120
}
116121

tests/ui/lint/wasm_c_abi_transition.rs

+6
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ pub fn call_other_fun(x: MyType) {
3939
unsafe { other_fun(x) } //~ERROR: wasm ABI transition
4040
//~^WARN: previously accepted
4141
}
42+
43+
// Zero-sized types are safe in both ABIs
44+
#[repr(C)]
45+
pub struct MyZstType;
46+
#[allow(improper_ctypes_definitions)]
47+
pub extern "C" fn zst_safe(_x: (), _y: MyZstType) {}

0 commit comments

Comments
 (0)