Skip to content

Commit

Permalink
fix up docs warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed May 13, 2024
1 parent 99e9508 commit b39b681
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
42 changes: 20 additions & 22 deletions src/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ use alloc::{
vec,
vec::Vec,
};
use core::mem::ManuallyDrop;
use core::ops::{Deref, DerefMut};
use core::{
mem::ManuallyDrop,
ops::{Deref, DerefMut},
};

/// As [`try_cast_box`](try_cast_box), but unwraps for you.
/// As [`try_cast_box`], but unwraps for you.
#[inline]
pub fn cast_box<A: NoUninit, B: AnyBitPattern>(input: Box<A>) -> Box<B> {
try_cast_box(input).map_err(|(e, _v)| e).unwrap()
}

/// Attempts to cast the content type of a [`Box`](alloc::boxed::Box).
/// Attempts to cast the content type of a [`Box`].
///
/// On failure you get back an error along with the starting `Box`.
///
Expand Down Expand Up @@ -139,12 +141,12 @@ pub fn try_zeroed_slice_box<T: Zeroable>(
}
}

/// As [`try_zeroed_slice_box`](try_zeroed_slice_box), but unwraps for you.
/// As [`try_zeroed_slice_box`], but unwraps for you.
pub fn zeroed_slice_box<T: Zeroable>(length: usize) -> Box<[T]> {
try_zeroed_slice_box(length).unwrap()
}

/// As [`try_cast_slice_box`](try_cast_slice_box), but unwraps for you.
/// As [`try_cast_slice_box`], but unwraps for you.
#[inline]
pub fn cast_slice_box<A: NoUninit, B: AnyBitPattern>(
input: Box<[A]>,
Expand Down Expand Up @@ -195,13 +197,13 @@ pub fn try_cast_slice_box<A: NoUninit, B: AnyBitPattern>(
}
}

/// As [`try_cast_vec`](try_cast_vec), but unwraps for you.
/// As [`try_cast_vec`], but unwraps for you.
#[inline]
pub fn cast_vec<A: NoUninit, B: AnyBitPattern>(input: Vec<A>) -> Vec<B> {
try_cast_vec(input).map_err(|(e, _v)| e).unwrap()
}

/// Attempts to cast the content type of a [`Vec`](alloc::vec::Vec).
/// Attempts to cast the content type of a [`Vec`].
///
/// On failure you get back an error along with the starting `Vec`.
///
Expand Down Expand Up @@ -300,15 +302,15 @@ pub fn pod_collect_to_vec<A: NoUninit, B: NoUninit + AnyBitPattern>(
dst
}

/// As [`try_cast_rc`](try_cast_rc), but unwraps for you.
/// As [`try_cast_rc`], but unwraps for you.
#[inline]
pub fn cast_rc<A: NoUninit + AnyBitPattern, B: NoUninit + AnyBitPattern>(
input: Rc<A>,
) -> Rc<B> {
try_cast_rc(input).map_err(|(e, _v)| e).unwrap()
}

/// Attempts to cast the content type of a [`Rc`](alloc::rc::Rc).
/// Attempts to cast the content type of a [`Rc`].
///
/// On failure you get back an error along with the starting `Rc`.
///
Expand Down Expand Up @@ -336,7 +338,7 @@ pub fn try_cast_rc<A: NoUninit + AnyBitPattern, B: NoUninit + AnyBitPattern>(
}
}

/// As [`try_cast_arc`](try_cast_arc), but unwraps for you.
/// As [`try_cast_arc`], but unwraps for you.
#[inline]
#[cfg(target_has_atomic = "ptr")]
pub fn cast_arc<A: NoUninit + AnyBitPattern, B: NoUninit + AnyBitPattern>(
Expand All @@ -345,7 +347,7 @@ pub fn cast_arc<A: NoUninit + AnyBitPattern, B: NoUninit + AnyBitPattern>(
try_cast_arc(input).map_err(|(e, _v)| e).unwrap()
}

/// Attempts to cast the content type of a [`Arc`](alloc::sync::Arc).
/// Attempts to cast the content type of a [`Arc`].
///
/// On failure you get back an error along with the starting `Arc`.
///
Expand Down Expand Up @@ -377,7 +379,7 @@ pub fn try_cast_arc<
}
}

/// As [`try_cast_slice_rc`](try_cast_slice_rc), but unwraps for you.
/// As [`try_cast_slice_rc`], but unwraps for you.
#[inline]
pub fn cast_slice_rc<
A: NoUninit + AnyBitPattern,
Expand Down Expand Up @@ -439,7 +441,7 @@ pub fn try_cast_slice_rc<
}
}

/// As [`try_cast_slice_arc`](try_cast_slice_arc), but unwraps for you.
/// As [`try_cast_slice_arc`], but unwraps for you.
#[inline]
#[cfg(target_has_atomic = "ptr")]
pub fn cast_slice_arc<
Expand Down Expand Up @@ -557,8 +559,7 @@ pub trait TransparentWrapperAlloc<Inner: ?Sized>:
}
}

/// Convert an [`Rc`](alloc::rc::Rc) to the inner type into an `Rc` to the
/// wrapper type.
/// Convert an [`Rc`] to the inner type into an `Rc` to the wrapper type.
#[inline]
fn wrap_rc(s: Rc<Inner>) -> Rc<Self> {
// The unsafe contract requires that these two have
Expand All @@ -584,8 +585,7 @@ pub trait TransparentWrapperAlloc<Inner: ?Sized>:
}
}

/// Convert an [`Arc`](alloc::sync::Arc) to the inner type into an `Arc` to
/// the wrapper type.
/// Convert an [`Arc`] to the inner type into an `Arc` to the wrapper type.
#[inline]
#[cfg(target_has_atomic = "ptr")]
fn wrap_arc(s: Arc<Inner>) -> Arc<Self> {
Expand Down Expand Up @@ -662,8 +662,7 @@ pub trait TransparentWrapperAlloc<Inner: ?Sized>:
}
}

/// Convert an [`Rc`](alloc::rc::Rc) to the wrapper type into an `Rc` to the
/// inner type.
/// Convert an [`Rc`] to the wrapper type into an `Rc` to the inner type.
#[inline]
fn peel_rc(s: Rc<Self>) -> Rc<Inner> {
// The unsafe contract requires that these two have
Expand All @@ -689,8 +688,7 @@ pub trait TransparentWrapperAlloc<Inner: ?Sized>:
}
}

/// Convert an [`Arc`](alloc::sync::Arc) to the wrapper type into an `Arc` to
/// the inner type.
/// Convert an [`Arc`] to the wrapper type into an `Arc` to the inner type.
#[inline]
#[cfg(target_has_atomic = "ptr")]
fn peel_arc(s: Arc<Self>) -> Arc<Inner> {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![no_std]
#![warn(missing_docs)]
#![allow(unexpected_cfgs)]
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::uninlined_format_args)]
#![cfg_attr(feature = "nightly_docs", feature(doc_cfg))]
Expand Down Expand Up @@ -83,7 +84,7 @@
//! instead of just for a select list of array lengths.
//! * `must_cast`: Provides the `must_` functions, which will compile error if
//! the requested cast can't be statically verified.
//! * `const_zeroed`: Provides the const [`zeroed`] function.
//! * `const_zeroed`: Provides a const version of the `zeroed` function.

#[cfg(all(target_arch = "aarch64", feature = "aarch64_simd"))]
use core::arch::aarch64;
Expand Down

2 comments on commit b39b681

@Urgau
Copy link
Contributor

@Urgau Urgau commented on b39b681 May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up, @Lokathor, with the release of rust-lang/cargo#13913 (in nightly-2024-05-19). Cargo has now gain the ability to declare --check-cfg args directly inside the [lints] table with [lints.rust.unexpected_cfgs.check-cfg]1:

Cargo.toml:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo)'] }

Note that the diagnostic output of the lint has been updated to suggest the [lints] approach first. You can use it to guide you through the --check-cfg arguments that may need to be added.

Footnotes

  1. take effect on Rust 1.80 (current nightly), is ignored on Rust 1.79 (current beta), and produce an unused warning below

@Lokathor
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, if you wanna PR a fix for that I'll merge it. Both ways seem fine to me, I don't quite follow why it'd want it in Cargo.toml instead of in the source code

Please sign in to comment.