Skip to content

Commit 4bf2794

Browse files
committed
custom mir: better type-checking
1 parent 0f9baa8 commit 4bf2794

File tree

1 file changed

+9
-7
lines changed
  • library/core/src/intrinsics

1 file changed

+9
-7
lines changed

library/core/src/intrinsics/mir.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -287,31 +287,33 @@ macro_rules! define {
287287
}
288288

289289
// Unwind actions
290+
pub struct UnwindActionArg;
290291
define!(
291292
"mir_unwind_continue",
292293
/// An unwind action that continues unwinding.
293-
fn UnwindContinue()
294+
fn UnwindContinue() -> UnwindActionArg
294295
);
295296
define!(
296297
"mir_unwind_unreachable",
297298
/// An unwind action that triggers undefined behaviour.
298-
fn UnwindUnreachable()
299+
fn UnwindUnreachable() -> UnwindActionArg
299300
);
300301
define!(
301302
"mir_unwind_terminate",
302303
/// An unwind action that terminates the execution.
303304
///
304305
/// `UnwindTerminate` can also be used as a terminator.
305-
fn UnwindTerminate(reason: UnwindTerminateReason)
306+
fn UnwindTerminate(reason: UnwindTerminateReason) -> UnwindActionArg
306307
);
307308
define!(
308309
"mir_unwind_cleanup",
309310
/// An unwind action that continues execution in a given basic blok.
310-
fn UnwindCleanup(goto: BasicBlock)
311+
fn UnwindCleanup(goto: BasicBlock) -> UnwindActionArg
311312
);
312313

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

316318
// Terminators
317319
define!("mir_return", fn Return() -> BasicBlock);
@@ -330,7 +332,7 @@ define!("mir_drop",
330332
/// - [`UnwindUnreachable`]
331333
/// - [`UnwindTerminate`]
332334
/// - [`UnwindCleanup`]
333-
fn Drop<T>(place: T, goto: (), unwind_action: ())
335+
fn Drop<T>(place: T, goto: ReturnToArg, unwind_action: UnwindActionArg)
334336
);
335337
define!("mir_call",
336338
/// Call a function.
@@ -345,7 +347,7 @@ define!("mir_call",
345347
/// - [`UnwindUnreachable`]
346348
/// - [`UnwindTerminate`]
347349
/// - [`UnwindCleanup`]
348-
fn Call(call: (), goto: (), unwind_action: ())
350+
fn Call(call: (), goto: ReturnToArg, unwind_action: UnwindActionArg)
349351
);
350352
define!("mir_unwind_resume",
351353
/// A terminator that resumes the unwinding.

0 commit comments

Comments
 (0)