Skip to content

Commit

Permalink
custom mir: better type-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 26, 2023
1 parent 0f9baa8 commit 4bf2794
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions library/core/src/intrinsics/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,31 +287,33 @@ macro_rules! define {
}

// Unwind actions
pub struct UnwindActionArg;
define!(
"mir_unwind_continue",
/// An unwind action that continues unwinding.
fn UnwindContinue()
fn UnwindContinue() -> UnwindActionArg
);
define!(
"mir_unwind_unreachable",
/// An unwind action that triggers undefined behaviour.
fn UnwindUnreachable()
fn UnwindUnreachable() -> UnwindActionArg
);
define!(
"mir_unwind_terminate",
/// An unwind action that terminates the execution.
///
/// `UnwindTerminate` can also be used as a terminator.
fn UnwindTerminate(reason: UnwindTerminateReason)
fn UnwindTerminate(reason: UnwindTerminateReason) -> UnwindActionArg
);
define!(
"mir_unwind_cleanup",
/// An unwind action that continues execution in a given basic blok.
fn UnwindCleanup(goto: BasicBlock)
fn UnwindCleanup(goto: BasicBlock) -> UnwindActionArg
);

// Return destination for `Call`
define!("mir_return_to", fn ReturnTo(goto: BasicBlock));
pub struct ReturnToArg;
define!("mir_return_to", fn ReturnTo(goto: BasicBlock) -> ReturnToArg);

// Terminators
define!("mir_return", fn Return() -> BasicBlock);
Expand All @@ -330,7 +332,7 @@ define!("mir_drop",
/// - [`UnwindUnreachable`]
/// - [`UnwindTerminate`]
/// - [`UnwindCleanup`]
fn Drop<T>(place: T, goto: (), unwind_action: ())
fn Drop<T>(place: T, goto: ReturnToArg, unwind_action: UnwindActionArg)
);
define!("mir_call",
/// Call a function.
Expand All @@ -345,7 +347,7 @@ define!("mir_call",
/// - [`UnwindUnreachable`]
/// - [`UnwindTerminate`]
/// - [`UnwindCleanup`]
fn Call(call: (), goto: (), unwind_action: ())
fn Call(call: (), goto: ReturnToArg, unwind_action: UnwindActionArg)
);
define!("mir_unwind_resume",
/// A terminator that resumes the unwinding.
Expand Down

0 comments on commit 4bf2794

Please sign in to comment.