Simplify the try intrinsic by using a callback in the catch block
This commit is contained in:
parent
5953c100d1
commit
1c950e5c6f
10 changed files with 150 additions and 126 deletions
|
|
@ -7,11 +7,14 @@ extern "C" {
|
|||
#[unwind(allow)]
|
||||
fn bar(data: *mut u8);
|
||||
}
|
||||
extern "Rust" {
|
||||
fn catch(data: *mut u8, exception: *mut u8);
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @foo
|
||||
#[no_mangle]
|
||||
pub unsafe fn foo() -> i32 {
|
||||
// CHECK: call void @bar
|
||||
// CHECK: ret i32 0
|
||||
std::intrinsics::r#try(|x| bar(x), 0 as *mut u8, 0 as *mut u8)
|
||||
std::intrinsics::r#try(|x| bar(x), 0 as *mut u8, |x, y| catch(x, y))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue