Skip to content

Commit d376ac8

Browse files
committed
core:: -> crate:: and # Safety docs for macros
1 parent 6af4863 commit d376ac8

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

library/core/src/num/int_sqrt.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ macro_rules! unsigned_fn {
159159
}
160160

161161
/// Generates the first stage of the computation after normalization.
162+
///
163+
/// # Safety
164+
///
165+
/// `$n` must be nonzero.
162166
macro_rules! first_stage {
163167
($original_bits:literal, $n:ident) => {{
164168
const N_SHIFT: u32 = $original_bits - 8;
@@ -169,6 +173,10 @@ macro_rules! first_stage {
169173
}
170174

171175
/// Generates a middle stage of the computation.
176+
///
177+
/// # Safety
178+
///
179+
/// `$s` must be nonzero.
172180
macro_rules! middle_stage {
173181
($original_bits:literal, $ty:ty, $n:ident, $s:ident, $r:ident) => {{
174182
// Inform the optimizer that `$s` is nonzero. This will allow it to
@@ -219,14 +227,18 @@ macro_rules! middle_stage {
219227
}
220228

221229
/// Generates the last stage of the computation before denormalization.
230+
///
231+
/// # Safety
232+
///
233+
/// `$s` must be nonzero.
222234
macro_rules! last_stage {
223235
($ty:ty, $n:ident, $s:ident, $r:ident) => {{
224236
// Inform the optimizer that `$s` is nonzero. This will allow it to
225237
// avoid generating code to handle division-by-zero panics in the
226238
// division below.
227239
//
228240
// 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) };
230242

231243
const HALF_BITS: u32 = <$ty>::BITS >> 1;
232244
const QUARTER_BITS: u32 = <$ty>::BITS >> 2;
@@ -248,6 +260,10 @@ macro_rules! last_stage {
248260

249261
/// Generates the stages of the computation between normalization and
250262
/// denormalization for [`u16`](prim@u16).
263+
///
264+
/// # Safety
265+
///
266+
/// `$n` must be nonzero.
251267
macro_rules! u16_stages {
252268
($n:ident) => {{
253269
let (s, r) = first_stage!(16, $n);
@@ -257,6 +273,10 @@ macro_rules! u16_stages {
257273

258274
/// Generates the stages of the computation between normalization and
259275
/// denormalization for [`u32`](prim@u32).
276+
///
277+
/// # Safety
278+
///
279+
/// `$n` must be nonzero.
260280
macro_rules! u32_stages {
261281
($n:ident) => {{
262282
let (s, r) = first_stage!(32, $n);
@@ -267,6 +287,10 @@ macro_rules! u32_stages {
267287

268288
/// Generates the stages of the computation between normalization and
269289
/// denormalization for [`u64`](prim@u64).
290+
///
291+
/// # Safety
292+
///
293+
/// `$n` must be nonzero.
270294
macro_rules! u64_stages {
271295
($n:ident) => {{
272296
let (s, r) = first_stage!(64, $n);
@@ -278,6 +302,10 @@ macro_rules! u64_stages {
278302

279303
/// Generates the stages of the computation between normalization and
280304
/// denormalization for [`u128`](prim@u128).
305+
///
306+
/// # Safety
307+
///
308+
/// `$n` must be nonzero.
281309
macro_rules! u128_stages {
282310
($n:ident) => {{
283311
let (s, r) = first_stage!(128, $n);

0 commit comments

Comments
 (0)