Skip to content

Commit 1890553

Browse files
committed
Auto merge of #3042 - rust-lang:rustup-2023-08-29, r=RalfJung
Automatic sync from rustc
2 parents 0970421 + ad14096 commit 1890553

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9334ec93541fd6963a3bfa2d2d09e3e33ac93131
1+
f3284dc3ad9254236d296daa1285dd273b492b01

tests/fail/panic/double_panic.stderr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ second
66
stack backtrace:
77
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
88
panic in a destructor during cleanup
9-
stack backtrace:
109
thread caused non-unwinding panic. aborting.
1110
error: abnormal termination: the program aborted execution
1211
--> RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC
@@ -19,7 +18,7 @@ LL | ABORT();
1918
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
2019
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
2120
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
22-
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
21+
= note: inside `core::panicking::panic_nounwind_nobacktrace` at RUSTLIB/core/src/panicking.rs:LL:CC
2322
= note: inside `core::panicking::panic_in_cleanup` at RUSTLIB/core/src/panicking.rs:LL:CC
2423
note: inside `main`
2524
--> $DIR/double_panic.rs:LL:CC
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::mem;
2+
use std::num;
3+
4+
fn test_abi_compat<T, U>(t: T, u: U) {
5+
fn id<T>(x: T) -> T {
6+
x
7+
}
8+
9+
// This checks ABI compatibility both for arguments and return values,
10+
// in both directions.
11+
let f: fn(T) -> T = id;
12+
let f: fn(U) -> U = unsafe { std::mem::transmute(f) };
13+
drop(f(u));
14+
15+
let f: fn(U) -> U = id;
16+
let f: fn(T) -> T = unsafe { std::mem::transmute(f) };
17+
drop(f(t));
18+
}
19+
20+
fn main() {
21+
test_abi_compat(0u32, 'x');
22+
test_abi_compat(&0u32, &([true; 4], [0u32; 0]));
23+
test_abi_compat(0u32, mem::MaybeUninit::new(0u32));
24+
test_abi_compat(42u32, num::NonZeroU32::new(1).unwrap());
25+
test_abi_compat(0u32, Some(num::NonZeroU32::new(1).unwrap()));
26+
test_abi_compat(0u32, 0i32);
27+
// Note that `bool` and `u8` are *not* compatible!
28+
// One of them has `arg_ext: Zext`, the other does not.
29+
}

0 commit comments

Comments
 (0)