Skip to content

Commit

Permalink
Start expecting some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jul 29, 2024
1 parent 3ff4ca1 commit e3b4ba3
Show file tree
Hide file tree
Showing 275 changed files with 435 additions and 599 deletions.
5 changes: 2 additions & 3 deletions necsim/core/bond/src/closed_open_unit_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use crate::ClosedUnitF64;

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct ClosedOpenUnitF64Error(f64);

impl fmt::Display for ClosedOpenUnitF64Error {
Expand All @@ -19,7 +19,7 @@ impl fmt::Display for ClosedOpenUnitF64Error {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Copy, Clone, Deserialize, Serialize, TypeLayout)]
#[repr(transparent)]
#[serde(try_from = "f64", into = "f64")]
Expand Down Expand Up @@ -88,7 +88,6 @@ impl ClosedOpenUnitF64 {
}

impl PartialEq for ClosedOpenUnitF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
5 changes: 2 additions & 3 deletions necsim/core/bond/src/closed_unit_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
use crate::{ClosedOpenUnitF64, OpenClosedUnitF64};

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct ClosedUnitF64Error(f64);

impl fmt::Display for ClosedUnitF64Error {
Expand All @@ -21,7 +21,7 @@ impl fmt::Display for ClosedUnitF64Error {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Copy, Clone, Serialize, Deserialize, TypeLayout)]
#[repr(transparent)]
#[serde(try_from = "f64", into = "f64")]
Expand Down Expand Up @@ -122,7 +122,6 @@ impl From<ClosedOpenUnitF64> for ClosedUnitF64 {
}

impl PartialEq for ClosedUnitF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
9 changes: 4 additions & 5 deletions necsim/core/bond/src/non_negative_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use necsim_core_maths::MathsCore;
use crate::{ClosedOpenUnitF64, ClosedUnitF64, NonPositiveF64, OpenClosedUnitF64, PositiveF64};

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct NonNegativeF64Error(f64);

impl fmt::Display for NonNegativeF64Error {
Expand All @@ -23,7 +23,7 @@ impl fmt::Display for NonNegativeF64Error {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Copy, Clone, Serialize, Deserialize, TypeLayout)]
#[repr(transparent)]
#[serde(try_from = "f64", into = "f64")]
Expand Down Expand Up @@ -123,14 +123,14 @@ impl From<u32> for NonNegativeF64 {
}

impl From<u64> for NonNegativeF64 {
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
fn from(value: u64) -> Self {
Self(value as f64)
}
}

impl From<usize> for NonNegativeF64 {
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
fn from(value: usize) -> Self {
Self(value as f64)
}
Expand Down Expand Up @@ -161,7 +161,6 @@ impl From<ClosedOpenUnitF64> for NonNegativeF64 {
}

impl PartialEq for NonNegativeF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
5 changes: 2 additions & 3 deletions necsim/core/bond/src/non_positive_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
use crate::NonNegativeF64;

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct NonPositiveF64Error(f64);

impl fmt::Display for NonPositiveF64Error {
Expand All @@ -20,7 +20,7 @@ impl fmt::Display for NonPositiveF64Error {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Copy, Clone, Serialize, Deserialize, TypeLayout)]
#[repr(transparent)]
#[serde(try_from = "f64", into = "f64")]
Expand Down Expand Up @@ -94,7 +94,6 @@ impl NonPositiveF64 {
}

impl PartialEq for NonPositiveF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
2 changes: 1 addition & 1 deletion necsim/core/bond/src/non_zero_one_u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::{convert::TryFrom, fmt, num::NonZeroU64};
use serde::{Deserialize, Deserializer, Serialize};

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct NonZeroOneU64Error(u64);

impl fmt::Display for NonZeroOneU64Error {
Expand Down
6 changes: 3 additions & 3 deletions necsim/core/bond/src/off_by_one_u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::{
use serde::{Deserialize, Deserializer, Serialize};

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct OffByOneU32Error(u64);

impl fmt::Display for OffByOneU32Error {
Expand Down Expand Up @@ -37,7 +37,7 @@ impl OffByOneU32 {
// Err(_) => Err(OffByOneU32Error(value)),
// }
match value.wrapping_sub(1) {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
value if value <= (u32::MAX as u64) => Ok(Self(value as u32)),
_ => Err(OffByOneU32Error(value)),
}
Expand All @@ -50,7 +50,7 @@ impl OffByOneU32 {
///
/// The value must be in {1, .., 2^32}.
pub const unsafe fn new_unchecked(value: u64) -> Self {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
Self(value.wrapping_sub(1) as u32)
}

Expand Down
14 changes: 7 additions & 7 deletions necsim/core/bond/src/off_by_one_u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Deserializer, Serialize};
use crate::{ClosedUnitF64, OffByOneU32};

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct OffByOneU64Error(u128);

impl fmt::Display for OffByOneU64Error {
Expand Down Expand Up @@ -40,7 +40,7 @@ impl OffByOneU64 {
// Err(_) => Err(OffByOneU64Error(value)),
// }
match value.wrapping_sub(1) {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
value if value < (u64::MAX as u128) => Ok(Self(value as u64)),
_ => Err(OffByOneU64Error(value)),
}
Expand All @@ -53,7 +53,7 @@ impl OffByOneU64 {
///
/// The value must be in {1, .., 2^64}.
pub const unsafe fn new_unchecked(value: u128) -> Self {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
Self(value.wrapping_sub(1) as u64)
}

Expand Down Expand Up @@ -128,7 +128,7 @@ impl From<OffByOneU64> for NonZeroU64 {
}

impl From<OffByOneU64> for f64 {
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
fn from(val: OffByOneU64) -> Self {
(val.0 as f64) + 1.0_f64
}
Expand Down Expand Up @@ -166,9 +166,9 @@ impl Mul<ClosedUnitF64> for OffByOneU64 {
type Output = Self;

fn mul(self, other: ClosedUnitF64) -> Self::Output {
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_sign_loss)]
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_possible_truncation)]
#[expect(clippy::cast_sign_loss)]
#[expect(clippy::cast_precision_loss)]
Self(((((self.get() as f64) * other.get()) as u128) - 1) as u64)
}
}
5 changes: 2 additions & 3 deletions necsim/core/bond/src/open_closed_unit_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
use crate::NonPositiveF64;

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct OpenClosedUnitF64Error(f64);

impl fmt::Display for OpenClosedUnitF64Error {
Expand All @@ -20,7 +20,7 @@ impl fmt::Display for OpenClosedUnitF64Error {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Copy, Clone, Deserialize, Serialize, TypeLayout)]
#[repr(transparent)]
#[serde(try_from = "f64", into = "f64")]
Expand Down Expand Up @@ -94,7 +94,6 @@ impl OpenClosedUnitF64 {
}

impl PartialEq for OpenClosedUnitF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
7 changes: 3 additions & 4 deletions necsim/core/bond/src/positive_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
use crate::NonNegativeF64;

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct PositiveF64Error(f64);

impl fmt::Display for PositiveF64Error {
Expand All @@ -21,7 +21,7 @@ impl fmt::Display for PositiveF64Error {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Copy, Clone, Serialize, Deserialize, TypeLayout)]
#[repr(transparent)]
#[serde(try_from = "f64", into = "f64")]
Expand Down Expand Up @@ -120,14 +120,13 @@ impl From<NonZeroU32> for PositiveF64 {
}

impl From<NonZeroU64> for PositiveF64 {
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
fn from(value: NonZeroU64) -> Self {
Self(value.get() as f64)
}
}

impl PartialEq for PositiveF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
2 changes: 0 additions & 2 deletions necsim/core/src/cogs/active_lineage_sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use super::{

use crate::{lineage::Lineage, simulation::partial::active_lineage_sampler::PartialSimulation};

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[allow(clippy::no_effect_underscore_binding)]
#[contract_trait]
pub trait ActiveLineageSampler<
M: MathsCore,
Expand Down
1 change: 0 additions & 1 deletion necsim/core/src/cogs/backup.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::ops::Deref;

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[contract_trait]
pub trait Backup: Sized {
#[must_use]
Expand Down
7 changes: 1 addition & 6 deletions necsim/core/src/cogs/coalescence_sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{

use super::{Habitat, LineageStore};

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[contract_trait]
pub trait CoalescenceSampler<M: MathsCore, H: Habitat<M>, S: LineageStore<M, H>>:
crate::cogs::Backup + core::fmt::Debug
Expand Down Expand Up @@ -68,11 +67,7 @@ impl CoalescenceRngSample {
pub fn sample_coalescence_index<M: MathsCore>(self, length: u32) -> u32 {
// attributes on expressions are experimental
// see https://github.com/rust-lang/rust/issues/15701
#[allow(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
clippy::cast_sign_loss
)]
#[expect(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
let index = M::floor(self.0.get() * f64::from(length)) as u32;
index
}
Expand Down
7 changes: 1 addition & 6 deletions necsim/core/src/cogs/dispersal_sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::{

use super::Habitat;

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[allow(clippy::no_effect_underscore_binding)]
#[allow(clippy::module_name_repetitions)]
#[contract_trait]
pub trait DispersalSampler<M: MathsCore, H: Habitat<M>, G: RngCore<M>>:
crate::cogs::Backup + core::fmt::Debug
Expand All @@ -25,9 +22,7 @@ pub trait DispersalSampler<M: MathsCore, H: Habitat<M>, G: RngCore<M>>:
) -> Location;
}

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[allow(clippy::no_effect_underscore_binding)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
#[contract_trait]
pub trait SeparableDispersalSampler<M: MathsCore, H: Habitat<M>, G: RngCore<M>>:
DispersalSampler<M, H, G>
Expand Down
7 changes: 1 addition & 6 deletions necsim/core/src/cogs/emigration_exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ use crate::{
simulation::partial::emigration_exit::PartialSimulation,
};

#[allow(
clippy::inline_always,
clippy::inline_fn_without_body,
clippy::too_many_arguments
)]
#[allow(clippy::no_effect_underscore_binding)]
#[expect(clippy::too_many_arguments)]
#[contract_trait]
pub trait EmigrationExit<M: MathsCore, H: Habitat<M>, G: RngCore<M>, S: LineageStore<M, H>>:
crate::cogs::Backup + core::fmt::Debug
Expand Down
1 change: 0 additions & 1 deletion necsim/core/src/cogs/event_sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct EventHandler<S, D, E> {
pub emigration: E,
}

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[contract_trait]
pub trait EventSampler<
M: MathsCore,
Expand Down
12 changes: 1 addition & 11 deletions necsim/core/src/cogs/habitat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ use crate::landscape::{IndexedLocation, LandscapeExtent, Location};

use super::{MathsCore, RngCore};

#[allow(
clippy::inline_always,
clippy::inline_fn_without_body,
clippy::no_effect_underscore_binding
)]
#[contract_trait]
pub trait Habitat<M: MathsCore>: crate::cogs::Backup + core::fmt::Debug + Sized {
type LocationIterator<'a>: Iterator<Item = Location> + 'a
Expand Down Expand Up @@ -60,12 +55,7 @@ pub trait Habitat<M: MathsCore>: crate::cogs::Backup + core::fmt::Debug + Sized
fn iter_habitable_locations(&self) -> Self::LocationIterator<'_>;
}

#[allow(clippy::module_name_repetitions)]
#[allow(
clippy::inline_always,
clippy::inline_fn_without_body,
clippy::no_effect_underscore_binding
)]
#[expect(clippy::module_name_repetitions)]
#[contract_trait]
pub trait UniformlySampleableHabitat<M: MathsCore, G: RngCore<M>>: Habitat<M> {
#[debug_ensures(
Expand Down
1 change: 0 additions & 1 deletion necsim/core/src/cogs/immigration_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::lineage::MigratingLineage;

use super::MathsCore;

#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[contract_trait]
pub trait ImmigrationEntry<M: MathsCore>: crate::cogs::Backup + core::fmt::Debug {
#[must_use]
Expand Down
1 change: 0 additions & 1 deletion necsim/core/src/cogs/lineage_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use core::hash::Hash;

use super::{Habitat, MathsCore};

#[allow(clippy::module_name_repetitions)]
pub trait LineageReference<M: MathsCore, H: Habitat<M>>:
crate::cogs::Backup + PartialEq + Eq + Hash + core::fmt::Debug
{
Expand Down
Loading

0 comments on commit e3b4ba3

Please sign in to comment.