File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
// ignore-windows: Unwind panicking does not currently work on Windows
2
+ #![ allow( const_err) ]
3
+
2
4
use std:: panic:: { catch_unwind, AssertUnwindSafe } ;
3
5
use std:: cell:: Cell ;
4
6
@@ -48,11 +50,16 @@ fn main() {
48
50
test ( |old_val| panic ! ( format!( "Hello from panic: {:?}" , old_val) ) ) ;
49
51
test ( |old_val| panic ! ( "Hello from panic: {:?}" , old_val) ) ;
50
52
test ( |_old_val| panic ! ( 1337 ) ) ;
53
+
51
54
// FIXME https://github.com/rust-lang/miri/issues/1071
52
55
//test(|_old_val| core::panic!("Hello from panic: core"));
53
56
//test(|old_val| core::panic!(&format!("Hello from panic: {:?}", old_val)));
54
57
//test(|old_val| core::panic!("Hello from panic: {:?}", old_val));
55
58
59
+ // Built-in panics
60
+ test ( |_old_val| { let _val = [ 0 , 1 , 2 ] [ 4 ] ; loop { } } ) ;
61
+ test ( |_old_val| { let _val = 1 /0 ; loop { } } ) ;
62
+
56
63
// Cleanup: reset to default hook.
57
64
drop ( std:: panic:: take_hook ( ) ) ;
58
65
Original file line number Diff line number Diff line change 1
- thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:47 :21
1
+ thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:49 :21
2
2
Caught panic message (&str): Hello from panic: std
3
- thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:48 :20
3
+ thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:50 :20
4
4
Caught panic message (String): Hello from panic: 1
5
- thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:49 :20
5
+ thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:51 :20
6
6
Caught panic message (String): Hello from panic: 2
7
- thread 'main' panicked at 'Box<Any>', $DIR/catch_panic.rs:50 :21
7
+ thread 'main' panicked at 'Box<Any>', $DIR/catch_panic.rs:52 :21
8
8
Failed get caught panic message.
9
+ thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4', $DIR/catch_panic.rs:60:34
10
+ Caught panic message (String): index out of bounds: the len is 3 but the index is 4
11
+ thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:61:34
12
+ Caught panic message (String): attempt to divide by zero
9
13
Success!
You can’t perform that action at this time.
0 commit comments