-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wf: ensure that non-Rust-functions have sized arguments, and everyone has sized return types #117351
wf: ensure that non-Rust-functions have sized arguments, and everyone has sized return types #117351
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -37,9 +37,11 @@ | |||||||||||
// revisions: wasi | ||||||||||||
//[wasi] compile-flags: --target wasm32-wasi | ||||||||||||
//[wasi] needs-llvm-components: webassembly | ||||||||||||
// revisions: nvptx64 | ||||||||||||
//[nvptx64] compile-flags: --target nvptx64-nvidia-cuda | ||||||||||||
//[nvptx64] needs-llvm-components: nvptx | ||||||||||||
// FIXME: disabled on nvptx64 since the target ABI fails the sanity check | ||||||||||||
/* revisions: nvptx64 | ||||||||||||
[nvptx64] compile-flags: --target nvptx64-nvidia-cuda | ||||||||||||
[nvptx64] needs-llvm-components: nvptx | ||||||||||||
*/ | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kjetilkjeka I had to disable this test on nvptx64 since the rust/compiler/rustc_target/src/abi/call/nvptx64.rs Lines 10 to 14 in b75b3b3
That's invalid since it doesn't say what to do for smaller aggregates, and they default to the (bad) This should be easy to reproduce by having a function like #[repr(C)]
struct ReprC1<T: ?Sized>(T);
extern "C" fn myfn(x: ReprC1<i32>) {} which will likely ICE on the current compiler already. |
||||||||||||
#![feature(rustc_attrs, unsized_fn_params, transparent_unions)] | ||||||||||||
#![cfg_attr(not(host), feature(no_core, lang_items), no_std, no_core)] | ||||||||||||
#![allow(unused, improper_ctypes_definitions, internal_features)] | ||||||||||||
|
@@ -307,19 +309,30 @@ mod arrays { | |||||||||||
} | ||||||||||||
|
||||||||||||
// Some tests with unsized types (not all wrappers are compatible with that). | ||||||||||||
macro_rules! assert_abi_compatible_unsized { | ||||||||||||
($name:ident, $t1:ty, $t2:ty) => { | ||||||||||||
mod $name { | ||||||||||||
use super::*; | ||||||||||||
// Declaring a `type` doesn't even check well-formedness, so we also declare a function. | ||||||||||||
fn check_wf(_x: $t1, _y: $t2) {} | ||||||||||||
// Can only test arguments and only the Rust ABI, since it's unsized. | ||||||||||||
#[rustc_abi(assert_eq)] | ||||||||||||
type TestRust = (fn($t1), fn($t2)); | ||||||||||||
} | ||||||||||||
}; | ||||||||||||
} | ||||||||||||
macro_rules! test_transparent_unsized { | ||||||||||||
($name:ident, $t:ty) => { | ||||||||||||
mod $name { | ||||||||||||
use super::*; | ||||||||||||
assert_abi_compatible!(wrap1, $t, Wrapper1<$t>); | ||||||||||||
assert_abi_compatible!(wrap1_reprc, ReprC1<$t>, ReprC1<Wrapper1<$t>>); | ||||||||||||
assert_abi_compatible!(wrap2, $t, Wrapper2<$t>); | ||||||||||||
assert_abi_compatible!(wrap2_reprc, ReprC1<$t>, ReprC1<Wrapper2<$t>>); | ||||||||||||
assert_abi_compatible_unsized!(wrap1, $t, Wrapper1<$t>); | ||||||||||||
assert_abi_compatible_unsized!(wrap1_reprc, ReprC1<$t>, ReprC1<Wrapper1<$t>>); | ||||||||||||
assert_abi_compatible_unsized!(wrap2, $t, Wrapper2<$t>); | ||||||||||||
assert_abi_compatible_unsized!(wrap2_reprc, ReprC1<$t>, ReprC1<Wrapper2<$t>>); | ||||||||||||
} | ||||||||||||
}; | ||||||||||||
} | ||||||||||||
|
||||||||||||
#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] | ||||||||||||
mod unsized_ { | ||||||||||||
use super::*; | ||||||||||||
test_transparent_unsized!(str_, str); | ||||||||||||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we revert eddfce5, which is no longer needed since we now reject the problematic type earlier.