Skip to content

Commit 503cdae

Browse files
authored
Unrolled build for rust-lang#139498
Rollup merge of rust-lang#139498 - alexcrichton:wasm-zst-safe, r=wesleywiser Ignore zero-sized types in wasm future-compat warning This commit fixes a false positive of the warning triggered for rust-lang#138762 and the fix is to codify that zero-sized types are "safe" in both the old and new ABIs.
2 parents a15cce2 + f9091e2 commit 503cdae

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Diff for: 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.is_zst() {
116+
return true;
117+
}
118+
114119
false
115120
}
116121

Diff for: 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)