File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( const_fn) ]
2
+ #![ feature( const_unreachable_unchecked) ]
3
+
4
+ const unsafe fn foo ( x : bool ) -> bool {
5
+ match x {
6
+ true => true ,
7
+ false => std:: hint:: unreachable_unchecked ( ) ,
8
+ }
9
+ }
10
+
11
+ const BAR : bool = unsafe { foo ( false ) } ;
12
+
13
+ fn main ( ) {
14
+ assert_eq ! ( BAR , true ) ;
15
+ }
Original file line number Diff line number Diff line change
1
+ error: any use of this value will cause an error
2
+ --> $SRC_DIR/libcore/hint.rs:LL:COL
3
+ |
4
+ LL | unsafe { intrinsics::unreachable() }
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
6
+ | |
7
+ | entering unreachable code
8
+ | inside `std::hint::unreachable_unchecked` at $SRC_DIR/libcore/hint.rs:LL:COL
9
+ | inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18
10
+ | inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28
11
+ |
12
+ ::: $DIR/const_unsafe_unreachable_ub.rs:11:1
13
+ |
14
+ LL | const BAR: bool = unsafe { foo(false) };
15
+ | ----------------------------------------
16
+ |
17
+ = note: `#[deny(const_err)]` on by default
18
+
19
+ error: aborting due to previous error
20
+
You can’t perform that action at this time.
0 commit comments