diff options
| author | The Miri Cronjob Bot <miri@cron.bot> | 2024-03-29 05:02:09 +0000 |
|---|---|---|
| committer | The Miri Cronjob Bot <miri@cron.bot> | 2024-03-29 05:02:09 +0000 |
| commit | ed29546a27db9fa024c6f99a7dd001e86d75e14f (patch) | |
| tree | a5635c4d1821e9114fe7cc27d00353f98cac5402 /compiler/rustc_codegen_cranelift/example | |
| parent | 29a59beaa6bc7841b12d6523bd638dbd6e7d0b01 (diff) | |
| parent | 5eb78c515c777c232c35b2e606bcec7cefe875af (diff) | |
| download | rust-ed29546a27db9fa024c6f99a7dd001e86d75e14f.tar.gz rust-ed29546a27db9fa024c6f99a7dd001e86d75e14f.zip | |
Merge from rustc
Diffstat (limited to 'compiler/rustc_codegen_cranelift/example')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/example/mini_core.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index 39988cf64e5..1cee5131907 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -465,6 +465,36 @@ pub fn panic(_msg: &'static str) -> ! { } } +macro_rules! panic_const { + ($($lang:ident = $message:expr,)+) => { + #[cfg(not(bootstrap))] + pub mod panic_const { + use super::*; + + $( + #[track_caller] + #[lang = stringify!($lang)] + pub fn $lang() -> ! { + panic($message); + } + )+ + } + } +} + +panic_const! { + panic_const_add_overflow = "attempt to add with overflow", + panic_const_sub_overflow = "attempt to subtract with overflow", + panic_const_mul_overflow = "attempt to multiply with overflow", + panic_const_div_overflow = "attempt to divide with overflow", + panic_const_rem_overflow = "attempt to calculate the remainder with overflow", + panic_const_neg_overflow = "attempt to negate with overflow", + panic_const_shr_overflow = "attempt to shift right with overflow", + panic_const_shl_overflow = "attempt to shift left with overflow", + panic_const_div_by_zero = "attempt to divide by zero", + panic_const_rem_by_zero = "attempt to calculate the remainder with a divisor of zero", +} + #[lang = "panic_bounds_check"] #[track_caller] fn panic_bounds_check(index: usize, len: usize) -> ! { |
