File tree 5 files changed +23
-1
lines changed
5 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ pub fn spin_loop() {
159
159
/// [`std::convert::identity`]: crate::convert::identity
160
160
#[ inline]
161
161
#[ unstable( feature = "bench_black_box" , issue = "64102" ) ]
162
- pub fn black_box < T > ( dummy : T ) -> T {
162
+ #[ rustc_const_unstable( feature = "const_black_box" , issue = "none" ) ]
163
+ pub const fn black_box < T > ( dummy : T ) -> T {
163
164
crate :: intrinsics:: black_box ( dummy)
164
165
}
Original file line number Diff line number Diff line change @@ -1940,6 +1940,7 @@ extern "rust-intrinsic" {
1940
1940
/// See documentation of [`std::hint::black_box`] for details.
1941
1941
///
1942
1942
/// [`std::hint::black_box`]: crate::hint::black_box
1943
+ #[ rustc_const_unstable( feature = "const_black_box" , issue = "none" ) ]
1943
1944
pub fn black_box < T > ( dummy : T ) -> T ;
1944
1945
}
1945
1946
Original file line number Diff line number Diff line change 103
103
#![ feature( const_arguments_as_str) ]
104
104
#![ feature( const_array_into_iter_constructors) ]
105
105
#![ feature( const_bigint_helper_methods) ]
106
+ #![ feature( const_black_box) ]
106
107
#![ feature( const_caller_location) ]
107
108
#![ feature( const_cell_into_inner) ]
108
109
#![ feature( const_char_convert) ]
Original file line number Diff line number Diff line change @@ -65,3 +65,18 @@ const fn test_write_bytes_in_const_contexts() {
65
65
assert ! ( TEST2 [ 1 ] == 16843009 ) ;
66
66
assert ! ( TEST2 [ 2 ] == 3 ) ;
67
67
}
68
+
69
+ #[ test]
70
+ fn test_hints_in_const_contexts ( ) {
71
+ use core:: intrinsics:: { likely, unlikely} ;
72
+
73
+ // In const contexts, they just return their argument.
74
+ const {
75
+ assert ! ( true == likely( true ) ) ;
76
+ assert ! ( false == likely( false ) ) ;
77
+ assert ! ( true == unlikely( true ) ) ;
78
+ assert ! ( false == unlikely( false ) ) ;
79
+ assert ! ( 42u32 == core:: intrinsics:: black_box( 42u32 ) ) ;
80
+ assert ! ( 42u32 == core:: hint:: black_box( 42u32 ) ) ;
81
+ }
82
+ }
Original file line number Diff line number Diff line change 2
2
#![ feature( array_chunks) ]
3
3
#![ feature( array_methods) ]
4
4
#![ feature( array_windows) ]
5
+ #![ feature( bench_black_box) ]
5
6
#![ feature( bool_to_option) ]
6
7
#![ feature( box_syntax) ]
7
8
#![ feature( cell_update) ]
8
9
#![ feature( cfg_panic) ]
9
10
#![ feature( cfg_target_has_atomic) ]
10
11
#![ feature( const_assume) ]
12
+ #![ feature( const_black_box) ]
11
13
#![ feature( const_bool_to_option) ]
12
14
#![ feature( const_cell_into_inner) ]
13
15
#![ feature( const_convert) ]
18
20
#![ feature( const_ptr_write) ]
19
21
#![ feature( const_ptr_offset) ]
20
22
#![ feature( const_trait_impl) ]
23
+ #![ feature( const_likely) ]
21
24
#![ feature( core_intrinsics) ]
22
25
#![ feature( core_private_bignum) ]
23
26
#![ feature( core_private_diy_float) ]
35
38
#![ feature( array_from_fn) ]
36
39
#![ feature( hashmap_internals) ]
37
40
#![ feature( try_find) ]
41
+ #![ feature( inline_const) ]
38
42
#![ feature( is_sorted) ]
39
43
#![ feature( pattern) ]
40
44
#![ feature( sort_internals) ]
You can’t perform that action at this time.
0 commit comments