Skip to content

Commit

Permalink
Remove explicit #[doc(cfg(...))] attributes
Browse files Browse the repository at this point in the history
These are superfluous now rust-lang/rust#89596
has landed.
  • Loading branch information
eggyal committed Oct 14, 2021
1 parent a0f939c commit 42ea7de
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/container/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use super::TypeIdDeterminationError::UnableToUpgradeWeakReference;
#[cfg(feature = "alloc")]
use core::any::type_name;

#[cfg(all(feature = "alloc", not(any(feature = "std", doc))))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::{boxed::Box, rc, sync};

#[cfg(any(feature = "std", doc))]
#[cfg(feature = "std")]
use std::{boxed::Box, rc, sync};

coercible_trait!(Any);
Expand Down
15 changes: 3 additions & 12 deletions src/container/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ macro_rules! coercibles {
$($rest:tt)*
}
) => {
$(
#[cfg(any(feature = $feature, doc))]
#[doc(cfg(feature = $feature))]
)?
$( #[cfg(feature = $feature)] )?
unsafe impl<$t> $crate::container::InnermostTypeId for $ty
where
$t: ?::core::marker::Sized + $crate::container::InnermostTypeId,
Expand All @@ -78,10 +75,7 @@ macro_rules! coercibles {
$($rest:tt)*
}
) => {
$(
#[cfg(any(feature = $feature, doc))]
#[doc(cfg(feature = $feature))]
)?
$( #[cfg(feature = $feature)] )?
impl<$t> $crate::container::Pointer for $ty
where
$t: ?::core::marker::Sized + $crate::container::Coercible,
Expand Down Expand Up @@ -130,10 +124,7 @@ macro_rules! coercibles {
$($rest:tt)*
}
) => {
$(
#[cfg(any(feature = $feature, doc))]
#[doc(cfg(feature = $feature))]
)?
$( #[cfg(feature = $feature)] )?
unsafe impl<$($lt,)? $t> $crate::container::Coercible for $ty
where
$t: ?::core::marker::Sized + $crate::container::Coercible,
Expand Down
4 changes: 2 additions & 2 deletions src/container/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use core::{
ptr,
};

#[cfg(all(any(feature = "alloc", doc), not(feature = "std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::{boxed::Box, rc, sync};

#[cfg(any(feature = "std", doc))]
#[cfg(feature = "std")]
use std::{boxed::Box, rc, sync};

#[cfg(feature = "alloc")]
Expand Down
10 changes: 3 additions & 7 deletions src/db/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ use std::{
fmt,
};

#[cfg(any(feature = "global", doc))]
#[cfg(feature = "global")]
use std::lazy::SyncOnceCell;

/// A [`TypeDatabase`] backed by a [`HashMap`].
#[derive(Debug, Default)]
#[doc(cfg(feature = "std"))]
pub struct HashMapTypeDatabase(HashMap<TypeId, Box<dyn Any + Send + Sync>>);

/// A [`TypeDatabaseEntry`] backed by a [`HashMap`].
#[doc(cfg(feature = "std"))]
pub struct HashMapTypeDatabaseEntry<U>(HashMap<TypeId, Metadata<U>>)
where
U: ?Sized;
Expand Down Expand Up @@ -55,14 +53,12 @@ macro_rules! rtti {

/// A global, immutable, thread-safe [`HashMapTypeDatabase`] that can be
/// initialized with [`rtti_global`].
#[cfg(any(feature = "global", doc))]
#[doc(cfg(feature = "global"))]
#[cfg(feature = "global")]
pub static DB: SyncOnceCell<HashMapTypeDatabase> = SyncOnceCell::new();

/// Instantiates the global [`DB`] with the provided entries.
#[macro_export]
#[cfg(any(feature = "global", doc))]
#[doc(cfg(feature = "global"))]
#[cfg(feature = "global")]
macro_rules! rtti_global {
($( $token:tt )+) => {{
$crate::db::hash_map::DB
Expand Down
3 changes: 1 addition & 2 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ pub mod error;
#[cfg(all(test, feature = "std"))]
mod tests;

#[cfg(any(feature = "std", doc))]
#[doc(cfg(feature = "std"))]
#[cfg(feature = "std")]
pub mod hash_map;

use crate::container::{Coerced, Coercible, InnermostTypeId, Metadata, Pointer};
Expand Down
28 changes: 13 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#![cfg_attr(not(any(feature = "std", doc)), no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(
any(feature = "global", doc, all(feature = "std", test)),
any(feature = "global", all(feature = "std", test)),
feature(once_cell)
)]
#![feature(
doc_cfg,
doc_cfg_hide,
generic_associated_types,
ptr_metadata,
unsize,
option_result_unwrap_unchecked
option_result_unwrap_unchecked,
)]
#![deny(missing_docs)]

Expand All @@ -20,8 +21,9 @@
//!
//! rattish is presently only experimental, and depends on unstable compiler
//! features including [`generic_associated_types`], [`ptr_metadata`] and
//! [`unsize`]; [`once_cell`] is used by [`DB`] (enabled by the `global`
//! feature). Accordingly, a nightly toolchain is required.
//! [`unsize`].
#![cfg_attr(feature = "global", doc = "[`once_cell`] is used by [`DB`] (enabled by the `global` feature).")]
//! Accordingly, a nightly toolchain is required.
//!
//! # Example
//! ```rust
Expand Down Expand Up @@ -95,7 +97,7 @@
//! [`ptr_metadata`]: https://doc.rust-lang.org/nightly/unstable-book/library-features/ptr-metadata.html
//! [`unsize`]: https://doc.rust-lang.org/nightly/unstable-book/library-features/unsize.html
#[cfg(all(any(feature = "alloc", doc), not(feature = "std")))]
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc;

pub mod container;
Expand All @@ -112,7 +114,7 @@ use db::{
TypeDatabaseEntryExt, TypeDatabaseExt,
};

#[cfg(any(feature = "global", doc))]
#[cfg(feature = "global")]
use db::{error::DatabaseError, hash_map::DB};

#[cfg(feature = "tracing")]
Expand Down Expand Up @@ -181,8 +183,7 @@ where
{
}

#[cfg(any(feature = "global", doc))]
#[doc(cfg(feature = "global"))]
#[cfg(feature = "global")]
/// A type whose implementations can be dynamically determined using the global
/// [`DB`].
pub trait GlobalDynImplements
Expand All @@ -201,8 +202,7 @@ where
}
}

#[cfg(any(feature = "global", doc))]
#[doc(cfg(feature = "global"))]
#[cfg(feature = "global")]
/// A type that can be dynamically cast using the global [`DB`].
pub trait GlobalDynCast
where
Expand All @@ -228,12 +228,10 @@ where
}
}

#[cfg(any(feature = "global", doc))]
#[doc(cfg(feature = "global"))]
#[cfg(feature = "global")]
impl<P> GlobalDynImplements for P where Self: InnermostTypeId {}

#[cfg(any(feature = "global", doc))]
#[doc(cfg(feature = "global"))]
#[cfg(feature = "global")]
impl<P> GlobalDynCast for P
where
Self: Pointer + InnermostTypeId,
Expand Down

0 comments on commit 42ea7de

Please sign in to comment.