diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-07-25 16:07:57 +0200 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-07-25 16:07:57 +0200 |
| commit | 640c3f730a998f7f5ba82ea4a2363d92064e7bc4 (patch) | |
| tree | bd7fd2c6eb9d736cfbc9f72535e1a36880e04d98 /example | |
| parent | 745193d1971620f73bbab3a2b9391728d9210d30 (diff) | |
| download | rust-640c3f730a998f7f5ba82ea4a2363d92064e7bc4.tar.gz rust-640c3f730a998f7f5ba82ea4a2363d92064e7bc4.zip | |
Merge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into sync_cg_clif-2022-07-25
Diffstat (limited to 'example')
| -rw-r--r-- | example/mini_core.rs | 6 | ||||
| -rw-r--r-- | example/mini_core_hello_world.rs | 42 | ||||
| -rw-r--r-- | example/std_example.rs | 19 |
3 files changed, 64 insertions, 3 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs index 489259d1a6b..8b6042a3d66 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -458,7 +458,7 @@ pub trait FnMut<Args>: FnOnce<Args> { #[lang = "panic"] #[track_caller] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\n\0" as *const str as *const i8); intrinsics::abort(); @@ -497,7 +497,7 @@ pub trait Deref { #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] #[rustc_nonnull_optimization_guaranteed] -pub struct NonNull<T: ?Sized>(pub *mut T); +pub struct NonNull<T: ?Sized>(pub *const T); impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {} impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {} @@ -521,7 +521,7 @@ impl<T: ?Sized> Drop for Box<T> { } } -impl<T> Deref for Box<T> { +impl<T: ?Sized> Deref for Box<T> { type Target = T; fn deref(&self) -> &Self::Target { diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 0f1245c2758..aa1f239bae2 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -124,6 +124,23 @@ fn call_return_u128_pair() { return_u128_pair(); } +#[repr(C)] +pub struct bool_11 { + field0: bool, + field1: bool, + field2: bool, + field3: bool, + field4: bool, + field5: bool, + field6: bool, + field7: bool, + field8: bool, + field9: bool, + field10: bool, +} + +extern "C" fn bool_struct_in_11(arg0: bool_11) {} + #[allow(unreachable_code)] // FIXME false positive fn main() { take_unique(Unique { @@ -134,6 +151,20 @@ fn main() { call_return_u128_pair(); + bool_struct_in_11(bool_11 { + field0: true, + field1: true, + field2: true, + field3: true, + field4: true, + field5: true, + field6: true, + field7: true, + field8: true, + field9: true, + field10: true, + }); + let slice = &[0, 1] as &[i32]; let slice_ptr = slice as *const [i32] as *const i32; @@ -299,6 +330,17 @@ fn main() { static REF1: &u8 = &42; static REF2: &u8 = REF1; assert_eq!(*REF1, *REF2); + + extern "C" { + type A; + } + + fn main() { + let x: &A = unsafe { &*(1usize as *const A) }; + + assert_eq!(unsafe { intrinsics::size_of_val(x) }, 0); + assert_eq!(unsafe { intrinsics::min_align_of_val(x) }, 1); +} } #[cfg(all(not(jit), target_arch = "x86_64", target_os = "linux"))] diff --git a/example/std_example.rs b/example/std_example.rs index 0a2bce2621d..0b5b6cd55d7 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -128,6 +128,25 @@ fn main() { 0 => loop {}, v => panic(v), }; + + if black_box(false) { + // Based on https://github.com/rust-lang/rust/blob/2f320a224e827b400be25966755a621779f797cc/src/test/ui/debuginfo/debuginfo_with_uninhabitable_field_and_unsized.rs + let _ = Foo::<dyn Send>::new(); + + #[allow(dead_code)] + struct Foo<T: ?Sized> { + base: Never, + value: T, + } + + impl<T: ?Sized> Foo<T> { + pub fn new() -> Box<Foo<T>> { + todo!() + } + } + + enum Never {} + } } fn panic(_: u128) { |
