Skip to content

Commit df93351

Browse files
committed
test unwind(abort) with Rust ABI
1 parent a010652 commit df93351

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/test/ui/abi/abort-on-c-abi.rs renamed to src/test/ui/panics/abort-on-panic.rs

+27-3
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,51 @@ use std::io::prelude::*;
1414
use std::io;
1515
use std::process::{Command, Stdio};
1616

17-
#[unwind(aborts)] // FIXME(#58794)
17+
#[unwind(aborts)] // FIXME(#58794) should work even without the attribute
1818
extern "C" fn panic_in_ffi() {
1919
panic!("Test");
2020
}
2121

22+
#[unwind(aborts)]
23+
extern "Rust" fn panic_in_rust_abi() {
24+
panic!("TestRust");
25+
}
26+
2227
fn test() {
2328
let _ = panic::catch_unwind(|| { panic_in_ffi(); });
2429
// The process should have aborted by now.
2530
io::stdout().write(b"This should never be printed.\n");
2631
let _ = io::stdout().flush();
2732
}
2833

34+
fn testrust() {
35+
let _ = panic::catch_unwind(|| { panic_in_rust_abi(); });
36+
// The process should have aborted by now.
37+
io::stdout().write(b"This should never be printed.\n");
38+
let _ = io::stdout().flush();
39+
}
40+
2941
fn main() {
3042
let args: Vec<String> = env::args().collect();
31-
if args.len() > 1 && args[1] == "test" {
32-
return test();
43+
if args.len() > 1 {
44+
// This is inside the self-executed command.
45+
match &*args[1] {
46+
"test" => return test(),
47+
"testrust" => return testrust(),
48+
_ => panic!("bad test"),
49+
}
3350
}
3451

52+
// These end up calling the self-execution branches above.
3553
let mut p = Command::new(&args[0])
3654
.stdout(Stdio::piped())
3755
.stdin(Stdio::piped())
3856
.arg("test").spawn().unwrap();
3957
assert!(!p.wait().unwrap().success());
58+
59+
let mut p = Command::new(&args[0])
60+
.stdout(Stdio::piped())
61+
.stdin(Stdio::piped())
62+
.arg("testrust").spawn().unwrap();
63+
assert!(!p.wait().unwrap().success());
4064
}

0 commit comments

Comments
 (0)