File tree Expand file tree Collapse file tree 3 files changed +17
-17
lines changed
src/test/ui/consts/const-eval Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 11use core:: any:: TypeId ;
2+ use core:: intrinsics:: assume;
23
34#[ test]
45fn test_typeid_sized_types ( ) {
@@ -20,3 +21,17 @@ fn test_typeid_unsized_types() {
2021 assert_eq ! ( TypeId :: of:: <Y >( ) , TypeId :: of:: <Y >( ) ) ;
2122 assert ! ( TypeId :: of:: <X >( ) != TypeId :: of:: <Y >( ) ) ;
2223}
24+
25+ // Check that `const_assume` feature allow `assume` intrinsic
26+ // to be used in const contexts.
27+ #[ test]
28+ fn test_assume_can_be_in_const_contexts ( ) {
29+ const unsafe fn foo ( x : usize , y : usize ) -> usize {
30+ // SAFETY: the entire function is not safe,
31+ // but it is just an example not used elsewhere.
32+ unsafe { assume ( y != 0 ) } ;
33+ x / y
34+ }
35+ let rs = unsafe { foo ( 42 , 97 ) } ;
36+ assert_eq ! ( rs, 0 ) ;
37+ }
Original file line number Diff line number Diff line change 77#![ feature( bound_cloned) ]
88#![ feature( box_syntax) ]
99#![ feature( cell_update) ]
10+ #![ feature( const_assume) ]
11+ #![ feature( core_intrinsics) ]
1012#![ feature( core_private_bignum) ]
1113#![ feature( core_private_diy_float) ]
1214#![ feature( debug_non_exhaustive) ]
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments