File tree 1 file changed +9
-8
lines changed
1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -141,17 +141,18 @@ const fn debug_check_data_len<T>(data: *const T, len: usize) {
141
141
assert ! ( is_aligned_and_not_null( data) , "attempt to create unaligned or null slice" ) ;
142
142
}
143
143
144
- const fn ctfe_check < T > ( _data : * const T ) {
145
- // It's impossible to check alignment in const fn.
146
- //
147
- // CTFE engine checks that the pointer is aligned and not null.
148
- }
144
+ const fn noop < T > ( _: * const T ) { }
149
145
150
146
// SAFETY:
151
- // - `calling from_raw_parts[_mut]` with arguments that fail to fulfil checks made here is UB, so unless UB is already triggered this is noop
152
- // - CTFE makes the same checks as `rt_check`, so behavior change is not observable due to compilation error
147
+ //
148
+ // `rt_check` is just a debug assert to hint users that they are causing UB,
149
+ // it is not required for safety (the safety must be guatanteed by
150
+ // the `from_raw_parts[_mut]` caller).
151
+ //
152
+ // Since the checks are not required, we ignore them in CTFE as they can't
153
+ // be done there (alignment does not make much sense there).
153
154
unsafe {
154
- crate :: intrinsics:: const_eval_select ( ( data, ) , ctfe_check , rt_check) ;
155
+ crate :: intrinsics:: const_eval_select ( ( data, ) , noop , rt_check) ;
155
156
}
156
157
157
158
assert ! (
You can’t perform that action at this time.
0 commit comments