@@ -159,6 +159,10 @@ macro_rules! unsigned_fn {
159
159
}
160
160
161
161
/// Generates the first stage of the computation after normalization.
162
+ ///
163
+ /// # Safety
164
+ ///
165
+ /// `$n` must be nonzero.
162
166
macro_rules! first_stage {
163
167
( $original_bits: literal, $n: ident) => { {
164
168
const N_SHIFT : u32 = $original_bits - 8 ;
@@ -169,6 +173,10 @@ macro_rules! first_stage {
169
173
}
170
174
171
175
/// Generates a middle stage of the computation.
176
+ ///
177
+ /// # Safety
178
+ ///
179
+ /// `$s` must be nonzero.
172
180
macro_rules! middle_stage {
173
181
( $original_bits: literal, $ty: ty, $n: ident, $s: ident, $r: ident) => { {
174
182
// Inform the optimizer that `$s` is nonzero. This will allow it to
@@ -219,14 +227,18 @@ macro_rules! middle_stage {
219
227
}
220
228
221
229
/// Generates the last stage of the computation before denormalization.
230
+ ///
231
+ /// # Safety
232
+ ///
233
+ /// `$s` must be nonzero.
222
234
macro_rules! last_stage {
223
235
( $ty: ty, $n: ident, $s: ident, $r: ident) => { {
224
236
// Inform the optimizer that `$s` is nonzero. This will allow it to
225
237
// avoid generating code to handle division-by-zero panics in the
226
238
// division below.
227
239
//
228
240
// SAFETY: See the proof in the `middle_stage` macro above.
229
- unsafe { core :: hint:: assert_unchecked( $s != 0 ) } ;
241
+ unsafe { crate :: hint:: assert_unchecked( $s != 0 ) } ;
230
242
231
243
const HALF_BITS : u32 = <$ty>:: BITS >> 1 ;
232
244
const QUARTER_BITS : u32 = <$ty>:: BITS >> 2 ;
@@ -248,6 +260,10 @@ macro_rules! last_stage {
248
260
249
261
/// Generates the stages of the computation between normalization and
250
262
/// denormalization for [`u16`](prim@u16).
263
+ ///
264
+ /// # Safety
265
+ ///
266
+ /// `$n` must be nonzero.
251
267
macro_rules! u16_stages {
252
268
( $n: ident) => { {
253
269
let ( s, r) = first_stage!( 16 , $n) ;
@@ -257,6 +273,10 @@ macro_rules! u16_stages {
257
273
258
274
/// Generates the stages of the computation between normalization and
259
275
/// denormalization for [`u32`](prim@u32).
276
+ ///
277
+ /// # Safety
278
+ ///
279
+ /// `$n` must be nonzero.
260
280
macro_rules! u32_stages {
261
281
( $n: ident) => { {
262
282
let ( s, r) = first_stage!( 32 , $n) ;
@@ -267,6 +287,10 @@ macro_rules! u32_stages {
267
287
268
288
/// Generates the stages of the computation between normalization and
269
289
/// denormalization for [`u64`](prim@u64).
290
+ ///
291
+ /// # Safety
292
+ ///
293
+ /// `$n` must be nonzero.
270
294
macro_rules! u64_stages {
271
295
( $n: ident) => { {
272
296
let ( s, r) = first_stage!( 64 , $n) ;
@@ -278,6 +302,10 @@ macro_rules! u64_stages {
278
302
279
303
/// Generates the stages of the computation between normalization and
280
304
/// denormalization for [`u128`](prim@u128).
305
+ ///
306
+ /// # Safety
307
+ ///
308
+ /// `$n` must be nonzero.
281
309
macro_rules! u128_stages {
282
310
( $n: ident) => { {
283
311
let ( s, r) = first_stage!( 128 , $n) ;
0 commit comments