Skip to content

Commit

Permalink
Remove doc(hidden) attr from items in trait impls (#1165)
Browse files Browse the repository at this point in the history
These attributes produce warnings like the following on nightly:

```
warning: `#[doc(hidden)]` is ignored on trait impl items
   --> src/indexes.rs:212:5
    |
212 |     #[doc(hidden)]
    |     ^^^^^^^^^^^^^^ help: remove this attribute
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
```

I verified that these attributes have no effect on stable (1.60.0) or
nightly (2022-05-16), so they can be safely removed.
  • Loading branch information
jturner314 committed Jul 30, 2022
1 parent 3c92c51 commit 0b80af3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 64 deletions.
1 change: 0 additions & 1 deletion src/data_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ where
}
}

#[doc(hidden)]
unsafe fn clone_from_with_ptr(
&mut self,
other: &Self,
Expand Down
8 changes: 0 additions & 8 deletions src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,18 @@ impl<D: Dimension + Copy> NdProducer for Indices<D> {

private_impl! {}

#[doc(hidden)]
fn raw_dim(&self) -> Self::Dim {
self.dim
}

#[doc(hidden)]
fn equal_dim(&self, dim: &Self::Dim) -> bool {
self.dim.equal(dim)
}

#[doc(hidden)]
fn as_ptr(&self) -> Self::Ptr {
IndexPtr { index: self.start }
}

#[doc(hidden)]
fn layout(&self) -> Layout {
if self.dim.ndim() <= 1 {
Layout::one_dimensional()
Expand All @@ -204,19 +200,16 @@ impl<D: Dimension + Copy> NdProducer for Indices<D> {
}
}

#[doc(hidden)]
unsafe fn as_ref(&self, ptr: Self::Ptr) -> Self::Item {
ptr.index.into_pattern()
}

#[doc(hidden)]
unsafe fn uget_ptr(&self, i: &Self::Dim) -> Self::Ptr {
let mut index = *i;
index += &self.start;
IndexPtr { index }
}

#[doc(hidden)]
fn stride_of(&self, axis: Axis) -> Self::Stride {
axis.index()
}
Expand All @@ -226,7 +219,6 @@ impl<D: Dimension + Copy> NdProducer for Indices<D> {
0
}

#[doc(hidden)]
fn split_at(self, axis: Axis, index: usize) -> (Self, Self) {
let start_a = self.start;
let mut start_b = start_a;
Expand Down
9 changes: 1 addition & 8 deletions src/iterators/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,42 +63,34 @@ impl<$($typarm)*> NdProducer for $fulltype {
type Ptr = *mut A;
type Stride = isize;

#[doc(hidden)]
fn raw_dim(&self) -> D {
self.$base.raw_dim()
}

#[doc(hidden)]
fn layout(&self) -> Layout {
self.$base.layout()
}

#[doc(hidden)]
fn as_ptr(&self) -> *mut A {
self.$base.as_ptr() as *mut _
}

#[doc(hidden)]
fn contiguous_stride(&self) -> isize {
self.$base.contiguous_stride()
}

#[doc(hidden)]
unsafe fn as_ref(&$self_, $ptr: *mut A) -> Self::Item {
$refexpr
}

#[doc(hidden)]
unsafe fn uget_ptr(&self, i: &Self::Dim) -> *mut A {
self.$base.uget_ptr(i)
}

#[doc(hidden)]
fn stride_of(&self, axis: Axis) -> isize {
self.$base.stride_of(axis)
}

#[doc(hidden)]
fn split_at(self, axis: Axis, index: usize) -> (Self, Self) {
let (a, b) = self.$base.split_at(axis, index);
($typename {
Expand All @@ -114,6 +106,7 @@ impl<$($typarm)*> NdProducer for $fulltype {
)*
})
}

private_impl!{}
}

Expand Down
22 changes: 8 additions & 14 deletions src/iterators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,15 +1105,14 @@ impl<'a, A, D: Dimension> NdProducer for AxisIter<'a, A, D> {
type Ptr = *mut A;
type Stride = isize;

#[doc(hidden)]
fn layout(&self) -> crate::Layout {
crate::Layout::one_dimensional()
}
#[doc(hidden)]

fn raw_dim(&self) -> Self::Dim {
Ix1(self.len())
}
#[doc(hidden)]

fn as_ptr(&self) -> Self::Ptr {
if self.len() > 0 {
// `self.iter.index` is guaranteed to be in-bounds if any of the
Expand All @@ -1131,28 +1130,26 @@ impl<'a, A, D: Dimension> NdProducer for AxisIter<'a, A, D> {
self.iter.stride
}

#[doc(hidden)]
unsafe fn as_ref(&self, ptr: Self::Ptr) -> Self::Item {
ArrayView::new_(
ptr,
self.iter.inner_dim.clone(),
self.iter.inner_strides.clone(),
)
}
#[doc(hidden)]

unsafe fn uget_ptr(&self, i: &Self::Dim) -> Self::Ptr {
self.iter.offset(self.iter.index + i[0])
}

#[doc(hidden)]
fn stride_of(&self, _axis: Axis) -> isize {
self.contiguous_stride()
}

#[doc(hidden)]
fn split_at(self, _axis: Axis, index: usize) -> (Self, Self) {
self.split_at(index)
}

private_impl! {}
}

Expand All @@ -1162,15 +1159,14 @@ impl<'a, A, D: Dimension> NdProducer for AxisIterMut<'a, A, D> {
type Ptr = *mut A;
type Stride = isize;

#[doc(hidden)]
fn layout(&self) -> crate::Layout {
crate::Layout::one_dimensional()
}
#[doc(hidden)]

fn raw_dim(&self) -> Self::Dim {
Ix1(self.len())
}
#[doc(hidden)]

fn as_ptr(&self) -> Self::Ptr {
if self.len() > 0 {
// `self.iter.index` is guaranteed to be in-bounds if any of the
Expand All @@ -1188,28 +1184,26 @@ impl<'a, A, D: Dimension> NdProducer for AxisIterMut<'a, A, D> {
self.iter.stride
}

#[doc(hidden)]
unsafe fn as_ref(&self, ptr: Self::Ptr) -> Self::Item {
ArrayViewMut::new_(
ptr,
self.iter.inner_dim.clone(),
self.iter.inner_strides.clone(),
)
}
#[doc(hidden)]

unsafe fn uget_ptr(&self, i: &Self::Dim) -> Self::Ptr {
self.iter.offset(self.iter.index + i[0])
}

#[doc(hidden)]
fn stride_of(&self, _axis: Axis) -> isize {
self.contiguous_stride()
}

#[doc(hidden)]
fn split_at(self, _axis: Axis, index: usize) -> (Self, Self) {
self.split_at(index)
}

private_impl! {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ macro_rules! private_decl {
() => {
/// This trait is private to implement; this method exists to make it
/// impossible to implement outside the crate.
#[doc(hidden)]
fn __private__(&self) -> crate::private::PrivateMarker;
}
}

macro_rules! private_impl {
() => {
#[doc(hidden)]
fn __private__(&self) -> crate::private::PrivateMarker {
crate::private::PrivateMarker
}
Expand Down

0 comments on commit 0b80af3

Please sign in to comment.