|
| 1 | +// Test that when we call a function with #[rustc_panic_entrypoint], we encounter an abort and do |
| 2 | +// not actually execute the function. Immediate-aborting panics are implemented by a rewrite of such |
| 3 | +// functions, so this tests that the rewrite works with Miri. |
| 4 | + |
| 5 | +//@compile-flags: -Cpanic=immediate-abort -Zunstable-options --target=x86_64-unknown-none |
| 6 | + |
| 7 | +#![no_std] |
| 8 | +#![no_core] |
| 9 | +#![no_main] |
| 10 | +#![feature(rustc_attrs, no_core, lang_items, intrinsics)] |
| 11 | +#![allow(internal_features)] |
| 12 | + |
| 13 | +#[lang = "pointee_sized"] |
| 14 | +#[diagnostic::on_unimplemented( |
| 15 | + message = "values of type `{Self}` may or may not have a size", |
| 16 | + label = "may or may not have a known size" |
| 17 | +)] |
| 18 | +pub trait PointeeSized {} |
| 19 | + |
| 20 | +#[lang = "meta_sized"] |
| 21 | +#[diagnostic::on_unimplemented( |
| 22 | + message = "the size for values of type `{Self}` cannot be known", |
| 23 | + label = "doesn't have a known size" |
| 24 | +)] |
| 25 | +pub trait MetaSized: PointeeSized {} |
| 26 | + |
| 27 | +#[lang = "sized"] |
| 28 | +#[diagnostic::on_unimplemented( |
| 29 | + message = "the size for values of type `{Self}` cannot be known at compilation time", |
| 30 | + label = "doesn't have a size known at compile-time" |
| 31 | +)] |
| 32 | +pub trait Sized: MetaSized {} |
| 33 | + |
| 34 | +#[rustc_nounwind] |
| 35 | +#[rustc_intrinsic] |
| 36 | +#[lang = "abort_intrinsic"] |
| 37 | +fn abort() -> !; |
| 38 | + |
| 39 | +#[no_mangle] |
| 40 | +fn miri_start(_argc: isize, _argv: *const *const u8) -> isize { |
| 41 | + panic_entrypoint(); //~ ERROR: abnormal termination: the program aborted execution |
| 42 | + 0 |
| 43 | +} |
| 44 | + |
| 45 | +#[rustc_panic_entrypoint] |
| 46 | +fn panic_entrypoint() {} |
0 commit comments