hashbrown icon indicating copy to clipboard operation
hashbrown copied to clipboard

Missing a number of `# Errors` and `# Safety` documentations in `raw`

Open steffahn opened this issue 3 years ago • 0 comments

A followup to #289 addressing the remaining clippy::pedantic options would be nice; clippy currently complains:

cargo clippy --all --tests --features raw -- -W clippy::pedantic
Output (click to expand)
warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:343:5
    |
343 | /     pub unsafe fn drop(&self) {
344 | |         self.as_ptr().drop_in_place();
345 | |     }
    | |_____^
    |
    = note: `#[warn(clippy::missing_safety_doc)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:347:5
    |
347 | /     pub unsafe fn read(&self) -> T {
348 | |         self.as_ptr().read()
349 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:351:5
    |
351 | /     pub unsafe fn write(&self, val: T) {
352 | |         self.as_ptr().write(val);
353 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:355:5
    |
355 | /     pub unsafe fn as_ref<'a>(&self) -> &'a T {
356 | |         &*self.as_ptr()
357 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:359:5
    |
359 | /     pub unsafe fn as_mut<'a>(&self) -> &'a mut T {
360 | |         &mut *self.as_ptr()
361 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:364:5
    |
364 | /     pub unsafe fn copy_from_nonoverlapping(&self, other: &Self) {
365 | |         self.as_ptr().copy_from_nonoverlapping(other.as_ptr(), 1);
366 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:413:5
    |
413 | /     pub fn try_with_capacity(capacity: usize) -> Result<Self, TryReserveError> {
414 | |         Self::try_with_capacity_in(capacity, Global)
415 | |     }
    | |_____^
    |
    = note: `-W clippy::missing-errors-doc` implied by `-W clippy::pedantic`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:482:5
    |
482 | /     pub fn try_with_capacity_in(capacity: usize, alloc: A) -> Result<Self, TryReserveError> {
483 | |         Self::fallible_with_capacity(alloc, capacity, Fallibility::Fallible)
484 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:510:5
    |
510 | /     pub unsafe fn data_end(&self) -> NonNull<T> {
511 | |         NonNull::new_unchecked(self.table.ctrl.as_ptr().cast())
512 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:523:5
    |
523 | /     pub unsafe fn bucket_index(&self, bucket: &Bucket<T>) -> usize {
524 | |         bucket.to_base_index(self.data_end())
525 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:529:5
    |
529 | /     pub unsafe fn bucket(&self, index: usize) -> Bucket<T> {
530 | |         debug_assert_ne!(self.table.bucket_mask, 0);
531 | |         debug_assert!(index < self.buckets());
532 | |         Bucket::from_base_index(self.data_end(), index)
533 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:538:5
    |
538 | /     pub unsafe fn erase_no_drop(&mut self, item: &Bucket<T>) {
539 | |         let index = self.bucket_index(item);
540 | |         self.table.erase(index);
541 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:547:5
    |
547 | /     pub unsafe fn erase(&mut self, item: Bucket<T>) {
548 | |         // Erase the element from the table first since drop might panic.
549 | |         self.erase_no_drop(&item);
550 | |         item.drop();
551 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:573:5
    |
573 | /     pub unsafe fn remove(&mut self, item: Bucket<T>) -> T {
574 | |         self.erase_no_drop(&item);
575 | |         item.read()
576 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:667:5
    |
667 | /     pub fn try_reserve(
668 | |         &mut self,
669 | |         additional: usize,
670 | |         hasher: impl Fn(&T) -> u64,
...   |
676 | |         }
677 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:754:5
    |
754 | /     pub fn try_insert_no_grow(&mut self, hash: u64, value: T) -> Result<Bucket<T>, T> {
755 | |         unsafe {
756 | |             match self.table.prepare_insert_no_grow(hash) {
757 | |                 Ok(index) => {
...   |
764 | |         }
765 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:782:5
    |
782 | /     pub unsafe fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket<T> {
783 | |         let (index, old_ctrl) = self.table.prepare_insert_slot(hash);
784 | |         let bucket = self.table.bucket(index);
785 | |
...   |
792 | |         bucket
793 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:802:5
    |
802 | /     pub unsafe fn replace_bucket_with<F>(&mut self, bucket: Bucket<T>, f: F) -> bool
803 | |     where
804 | |         F: FnOnce(T) -> Option<T>,
805 | |     {
...   |
819 | |         }
820 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:946:5
    |
946 | /     pub unsafe fn iter(&self) -> RawIter<T> {
947 | |         let data = Bucket::from_base_index(self.data_end(), 0);
948 | |         RawIter {
949 | |             iter: RawIterRange::new(self.table.ctrl.as_ptr(), data, self.table.buckets()),
950 | |             items: self.table.items,
951 | |         }
952 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:965:5
    |
965 | /     pub unsafe fn iter_hash(&self, hash: u64) -> RawIterHash<'_, T, A> {
966 | |         RawIterHash::new(self, hash)
967 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:987:5
    |
987 | /     pub unsafe fn drain_iter_from(&mut self, iter: RawIter<T>) -> RawDrain<'_, T, A> {
988 | |         debug_assert_eq!(iter.len(), self.len());
989 | |         RawDrain {
990 | |             iter,
...   |
994 | |         }
995 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
    --> src/raw/mod.rs:1003:5
     |
1003 | /     pub unsafe fn into_iter_from(self, iter: RawIter<T>) -> RawIntoIter<T, A> {
1004 | |         debug_assert_eq!(iter.len(), self.len());
1005 | |
1006 | |         let alloc = self.table.alloc.clone();
...    |
1013 | |         }
1014 | |     }
     | |_____^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: 22 warnings emitted

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:343:5
    |
343 | /     pub unsafe fn drop(&self) {
344 | |         self.as_ptr().drop_in_place();
345 | |     }
    | |_____^
    |
    = note: `#[warn(clippy::missing_safety_doc)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:347:5
    |
347 | /     pub unsafe fn read(&self) -> T {
348 | |         self.as_ptr().read()
349 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:351:5
    |
351 | /     pub unsafe fn write(&self, val: T) {
352 | |         self.as_ptr().write(val);
353 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:355:5
    |
355 | /     pub unsafe fn as_ref<'a>(&self) -> &'a T {
356 | |         &*self.as_ptr()
357 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:359:5
    |
359 | /     pub unsafe fn as_mut<'a>(&self) -> &'a mut T {
360 | |         &mut *self.as_ptr()
361 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:364:5
    |
364 | /     pub unsafe fn copy_from_nonoverlapping(&self, other: &Self) {
365 | |         self.as_ptr().copy_from_nonoverlapping(other.as_ptr(), 1);
366 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:413:5
    |
413 | /     pub fn try_with_capacity(capacity: usize) -> Result<Self, TryReserveError> {
414 | |         Self::try_with_capacity_in(capacity, Global)
415 | |     }
    | |_____^
    |
    = note: `-W clippy::missing-errors-doc` implied by `-W clippy::pedantic`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:482:5
    |
482 | /     pub fn try_with_capacity_in(capacity: usize, alloc: A) -> Result<Self, TryReserveError> {
483 | |         Self::fallible_with_capacity(alloc, capacity, Fallibility::Fallible)
484 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:510:5
    |
510 | /     pub unsafe fn data_end(&self) -> NonNull<T> {
511 | |         NonNull::new_unchecked(self.table.ctrl.as_ptr().cast())
512 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:523:5
    |
523 | /     pub unsafe fn bucket_index(&self, bucket: &Bucket<T>) -> usize {
524 | |         bucket.to_base_index(self.data_end())
525 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:529:5
    |
529 | /     pub unsafe fn bucket(&self, index: usize) -> Bucket<T> {
530 | |         debug_assert_ne!(self.table.bucket_mask, 0);
531 | |         debug_assert!(index < self.buckets());
532 | |         Bucket::from_base_index(self.data_end(), index)
533 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:538:5
    |
538 | /     pub unsafe fn erase_no_drop(&mut self, item: &Bucket<T>) {
539 | |         let index = self.bucket_index(item);
540 | |         self.table.erase(index);
541 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:547:5
    |
547 | /     pub unsafe fn erase(&mut self, item: Bucket<T>) {
548 | |         // Erase the element from the table first since drop might panic.
549 | |         self.erase_no_drop(&item);
550 | |         item.drop();
551 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:573:5
    |
573 | /     pub unsafe fn remove(&mut self, item: Bucket<T>) -> T {
574 | |         self.erase_no_drop(&item);
575 | |         item.read()
576 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:667:5
    |
667 | /     pub fn try_reserve(
668 | |         &mut self,
669 | |         additional: usize,
670 | |         hasher: impl Fn(&T) -> u64,
...   |
676 | |         }
677 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: docs for function returning `Result` missing `# Errors` section
   --> src/raw/mod.rs:754:5
    |
754 | /     pub fn try_insert_no_grow(&mut self, hash: u64, value: T) -> Result<Bucket<T>, T> {
755 | |         unsafe {
756 | |             match self.table.prepare_insert_no_grow(hash) {
757 | |                 Ok(index) => {
...   |
764 | |         }
765 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:782:5
    |
782 | /     pub unsafe fn insert_no_grow(&mut self, hash: u64, value: T) -> Bucket<T> {
783 | |         let (index, old_ctrl) = self.table.prepare_insert_slot(hash);
784 | |         let bucket = self.table.bucket(index);
785 | |
...   |
792 | |         bucket
793 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:802:5
    |
802 | /     pub unsafe fn replace_bucket_with<F>(&mut self, bucket: Bucket<T>, f: F) -> bool
803 | |     where
804 | |         F: FnOnce(T) -> Option<T>,
805 | |     {
...   |
819 | |         }
820 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:946:5
    |
946 | /     pub unsafe fn iter(&self) -> RawIter<T> {
947 | |         let data = Bucket::from_base_index(self.data_end(), 0);
948 | |         RawIter {
949 | |             iter: RawIterRange::new(self.table.ctrl.as_ptr(), data, self.table.buckets()),
950 | |             items: self.table.items,
951 | |         }
952 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:965:5
    |
965 | /     pub unsafe fn iter_hash(&self, hash: u64) -> RawIterHash<'_, T, A> {
966 | |         RawIterHash::new(self, hash)
967 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
   --> src/raw/mod.rs:987:5
    |
987 | /     pub unsafe fn drain_iter_from(&mut self, iter: RawIter<T>) -> RawDrain<'_, T, A> {
988 | |         debug_assert_eq!(iter.len(), self.len());
989 | |         RawDrain {
990 | |             iter,
...   |
994 | |         }
995 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: unsafe function's docs miss `# Safety` section
    --> src/raw/mod.rs:1003:5
     |
1003 | /     pub unsafe fn into_iter_from(self, iter: RawIter<T>) -> RawIntoIter<T, A> {
1004 | |         debug_assert_eq!(iter.len(), self.len());
1005 | |
1006 | |         let alloc = self.table.alloc.clone();
...    |
1013 | |         }
1014 | |     }
     | |_____^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc

warning: 22 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

Once all of the missing # Errors and/or all of the missing # Safety comments are added, the corresponding -A… option should be removed from the cargo clippy call in ci/tools.sh.

steffahn avatar Aug 13 '21 21:08 steffahn