Skip to content

Commit 297479c

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 8525cfe + 6556e9d commit 297479c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/fail/intrinsic_fallback_is_spec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(rustc_attrs)]
1+
#![feature(intrinsics, rustc_attrs)]
22

33
#[rustc_intrinsic]
44
#[rustc_nounwind]

tests/pass/function_calls/abi_compat.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(never_type)]
2+
13
use std::rc::Rc;
24
use std::{mem, num, ptr};
35

@@ -12,6 +14,18 @@ fn id<T>(x: T) -> T {
1214
x
1315
}
1416

17+
#[derive(Copy, Clone)]
18+
enum Either<T, U> {
19+
Left(T),
20+
Right(U),
21+
}
22+
#[derive(Copy, Clone)]
23+
enum Either2<T, U> {
24+
Left(T),
25+
#[allow(unused)]
26+
Right(U, ()),
27+
}
28+
1529
fn test_abi_compat<T: Clone, U: Clone>(t: T, u: U) {
1630
fn id<T>(x: T) -> T {
1731
x
@@ -81,6 +95,8 @@ fn main() {
8195
test_abi_compat(main as fn(), id::<i32> as fn(i32) -> i32);
8296
// - 1-ZST
8397
test_abi_compat((), [0u8; 0]);
98+
99+
// Guaranteed null-pointer-layout optimizations:
84100
// - Guaranteed Option<X> null-pointer-optimizations (RFC 3391).
85101
test_abi_compat(&0u32 as *const u32, Some(&0u32));
86102
test_abi_compat(main as fn(), Some(main as fn()));
@@ -89,6 +105,7 @@ fn main() {
89105
test_abi_compat(0u32, Some(Wrapper(num::NonZeroU32::new(1u32).unwrap())));
90106
// - Guaranteed Result<X, ZST1> does the same as Option<X> (RFC 3391)
91107
test_abi_compat(&0u32 as *const u32, Result::<_, ()>::Ok(&0u32));
108+
test_abi_compat(&0u32 as *const u32, Result::<_, !>::Ok(&0u32));
92109
test_abi_compat(main as fn(), Result::<_, ()>::Ok(main as fn()));
93110
test_abi_compat(0u32, Result::<_, ()>::Ok(num::NonZeroU32::new(1).unwrap()));
94111
test_abi_compat(&0u32 as *const u32, Result::<_, ()>::Ok(Wrapper(&0u32)));
@@ -99,6 +116,13 @@ fn main() {
99116
test_abi_compat(0u32, Result::<(), _>::Err(num::NonZeroU32::new(1).unwrap()));
100117
test_abi_compat(&0u32 as *const u32, Result::<(), _>::Err(Wrapper(&0u32)));
101118
test_abi_compat(0u32, Result::<(), _>::Err(Wrapper(num::NonZeroU32::new(1).unwrap())));
119+
// - Guaranteed null-pointer-optimizations for custom option-like types
120+
test_abi_compat(&0u32 as *const u32, Either::<_, ()>::Left(&0u32));
121+
test_abi_compat(&0u32 as *const u32, Either::<_, !>::Left(&0u32));
122+
test_abi_compat(&0u32 as *const u32, Either::<(), _>::Right(&0u32));
123+
test_abi_compat(&0u32 as *const u32, Either::<!, _>::Right(&0u32));
124+
test_abi_compat(&0u32 as *const u32, Either2::<_, ()>::Left(&0u32));
125+
test_abi_compat(&0u32 as *const u32, Either2::<_, [u8; 0]>::Left(&0u32));
102126

103127
// These must work for *any* type, since we guarantee that `repr(transparent)` is ABI-compatible
104128
// with the wrapped field.

0 commit comments

Comments
 (0)