mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Extend clippy lints
This commit is contained in:
parent
05f387e41f
commit
7b8ad58906
|
@ -17,6 +17,11 @@
|
||||||
#![deny(unreachable_pub)]
|
#![deny(unreachable_pub)]
|
||||||
#![deny(clippy::missing_safety_doc)]
|
#![deny(clippy::missing_safety_doc)]
|
||||||
#![deny(clippy::undocumented_unsafe_blocks)]
|
#![deny(clippy::undocumented_unsafe_blocks)]
|
||||||
|
#![deny(clippy::manual_assert)]
|
||||||
|
#![deny(clippy::default_trait_access)]
|
||||||
|
#![deny(clippy::missing_panics_doc)]
|
||||||
|
#![deny(clippy::doc_markdown)]
|
||||||
|
#![deny(clippy::return_self_not_must_use)]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
@ -104,7 +109,7 @@ type HashType = u32;
|
||||||
///
|
///
|
||||||
/// The API surface provided is incredibly similar to the
|
/// The API surface provided is incredibly similar to the
|
||||||
/// [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html)
|
/// [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html)
|
||||||
/// implementation with fewer guarantees, and better optimised for the GameBoy Advance.
|
/// implementation with fewer guarantees, and better optimised for the `GameBoy Advance`.
|
||||||
///
|
///
|
||||||
/// [`Eq`]: https://doc.rust-lang.org/core/cmp/trait.Eq.html
|
/// [`Eq`]: https://doc.rust-lang.org/core/cmp/trait.Eq.html
|
||||||
/// [`Hash`]: https://doc.rust-lang.org/core/hash/trait.Hash.html
|
/// [`Hash`]: https://doc.rust-lang.org/core/hash/trait.Hash.html
|
||||||
|
@ -179,7 +184,7 @@ impl<K, V, ALLOCATOR: ClonableAllocator> HashMap<K, V, ALLOCATOR> {
|
||||||
pub fn with_size_in(size: usize, alloc: ALLOCATOR) -> Self {
|
pub fn with_size_in(size: usize, alloc: ALLOCATOR) -> Self {
|
||||||
Self {
|
Self {
|
||||||
nodes: NodeStorage::with_size_in(size, alloc),
|
nodes: NodeStorage::with_size_in(size, alloc),
|
||||||
hasher: Default::default(),
|
hasher: BuildHasherDefault::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +201,10 @@ impl<K, V, ALLOCATOR: ClonableAllocator> HashMap<K, V, ALLOCATOR> {
|
||||||
|
|
||||||
/// Creates an empty `HashMap` which can hold at least `capacity` elements before resizing. The actual
|
/// Creates an empty `HashMap` which can hold at least `capacity` elements before resizing. The actual
|
||||||
/// internal size may be larger as it must be a power of 2
|
/// internal size may be larger as it must be a power of 2
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if capacity is larger than 2^32 * .85
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_capacity_in(capacity: usize, alloc: ALLOCATOR) -> Self {
|
pub fn with_capacity_in(capacity: usize, alloc: ALLOCATOR) -> Self {
|
||||||
for i in 0..32 {
|
for i in 0..32 {
|
||||||
|
@ -511,7 +520,7 @@ impl<'a, K, V, ALLOCATOR: ClonableAllocator> IntoIterator for &'a HashMap<K, V,
|
||||||
/// An iterator over entries of a [`HashMap`]
|
/// An iterator over entries of a [`HashMap`]
|
||||||
///
|
///
|
||||||
/// This struct is created using the `into_iter()` method on [`HashMap`] as part of its implementation
|
/// This struct is created using the `into_iter()` method on [`HashMap`] as part of its implementation
|
||||||
/// of the IntoIterator trait.
|
/// of the `IntoIterator` trait.
|
||||||
pub struct IterOwned<K, V, ALLOCATOR: Allocator = Global> {
|
pub struct IterOwned<K, V, ALLOCATOR: Allocator = Global> {
|
||||||
map: HashMap<K, V, ALLOCATOR>,
|
map: HashMap<K, V, ALLOCATOR>,
|
||||||
at: usize,
|
at: usize,
|
||||||
|
@ -548,7 +557,7 @@ impl<K, V, ALLOCATOR: ClonableAllocator> Iterator for IterOwned<K, V, ALLOCATOR>
|
||||||
/// An iterator over entries of a [`HashMap`]
|
/// An iterator over entries of a [`HashMap`]
|
||||||
///
|
///
|
||||||
/// This struct is created using the `into_iter()` method on [`HashMap`] as part of its implementation
|
/// This struct is created using the `into_iter()` method on [`HashMap`] as part of its implementation
|
||||||
/// of the IntoIterator trait.
|
/// of the `IntoIterator` trait.
|
||||||
impl<K, V, ALLOCATOR: ClonableAllocator> IntoIterator for HashMap<K, V, ALLOCATOR> {
|
impl<K, V, ALLOCATOR: ClonableAllocator> IntoIterator for HashMap<K, V, ALLOCATOR> {
|
||||||
type Item = (K, V);
|
type Item = (K, V);
|
||||||
type IntoIter = IterOwned<K, V, ALLOCATOR>;
|
type IntoIter = IterOwned<K, V, ALLOCATOR>;
|
||||||
|
@ -748,6 +757,7 @@ where
|
||||||
|
|
||||||
/// Provides in-place mutable access to an occupied entry before any potential inserts
|
/// Provides in-place mutable access to an occupied entry before any potential inserts
|
||||||
/// into the map.
|
/// into the map.
|
||||||
|
#[must_use]
|
||||||
pub fn and_modify<F>(self, f: F) -> Self
|
pub fn and_modify<F>(self, f: F) -> Self
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut V),
|
F: FnOnce(&mut V),
|
||||||
|
@ -943,7 +953,7 @@ mod test {
|
||||||
let mut max_found = -1;
|
let mut max_found = -1;
|
||||||
let mut num_found = 0;
|
let mut num_found = 0;
|
||||||
|
|
||||||
for (_, value) in map.into_iter() {
|
for (_, value) in map {
|
||||||
max_found = max_found.max(value);
|
max_found = max_found.max(value);
|
||||||
num_found += 1;
|
num_found += 1;
|
||||||
}
|
}
|
||||||
|
@ -993,9 +1003,7 @@ mod test {
|
||||||
|
|
||||||
impl Drop for NoisyDrop {
|
impl Drop for NoisyDrop {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if self.dropped {
|
assert!(!self.dropped, "NoisyDropped dropped twice");
|
||||||
panic!("NoisyDropped dropped twice");
|
|
||||||
}
|
|
||||||
|
|
||||||
self.dropped = true;
|
self.dropped = true;
|
||||||
}
|
}
|
||||||
|
@ -1085,7 +1093,7 @@ mod test {
|
||||||
impl DropRegistry {
|
impl DropRegistry {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
are_dropped: Default::default(),
|
are_dropped: RefCell::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,9 +132,11 @@ impl<K, V> Node<K, V> {
|
||||||
|
|
||||||
pub(crate) fn decrement_distance(&mut self) {
|
pub(crate) fn decrement_distance(&mut self) {
|
||||||
self.distance_to_initial_bucket -= 1;
|
self.distance_to_initial_bucket -= 1;
|
||||||
if self.distance_to_initial_bucket < 0 {
|
|
||||||
panic!("Cannot decrement distance to below 0");
|
assert!(
|
||||||
}
|
self.distance_to_initial_bucket >= 0,
|
||||||
|
"Cannot decrement distance below 0"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn distance(&self) -> i32 {
|
pub(crate) fn distance(&self) -> i32 {
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl<K, V, ALLOCATOR: ClonableAllocator> NodeStorage<K, V, ALLOCATOR> {
|
||||||
|
|
||||||
let mut nodes = Vec::with_capacity_in(capacity, alloc);
|
let mut nodes = Vec::with_capacity_in(capacity, alloc);
|
||||||
for _ in 0..capacity {
|
for _ in 0..capacity {
|
||||||
nodes.push(Default::default());
|
nodes.push(Node::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Reference in a new issue