Skip to content

Commit

Permalink
Lint: Suppress some lint from no-default-features.
Browse files Browse the repository at this point in the history
I am not sure why the `allow(dead_code)` are needed, but it must be that
there are some builds where they are unused despite the `cfg()`s. I have
confirmed that removing the entire import causes the build to fail.
  • Loading branch information
kpreid committed Sep 21, 2024
1 parent cfe2e93 commit 1c7375f
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
not(any(test, feature = "arbitrary")),
warn(clippy::std_instead_of_core, clippy::std_instead_of_alloc)
)]
#![cfg_attr(not(feature = "std"), expect(clippy::arc_with_non_send_sync))]
#![cfg_attr(not(feature = "std"), allow(clippy::arc_with_non_send_sync))]
#![warn(clippy::missing_inline_in_public_items)]

#[cfg(any(feature = "std", test))]
Expand Down
6 changes: 3 additions & 3 deletions all-is-cubes-base/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ macro_rules! notnan {
};
}

#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", test)))]
#[allow(dead_code, reason = "unclear why this warns even though it is needed")]
/// Identical to [`num_traits::Euclid`] except that its signatures are compatible with
/// `std` versions.
///
/// Note: this code is duplicated between `all-is-cubes` and
/// `all-is-cubes-base` so that it doesn't need to be public.
pub(crate) trait Euclid {
#[allow(dead_code)]
fn div_euclid(self, rhs: Self) -> Self;
fn rem_euclid(self, rhs: Self) -> Self;
}
#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", test)))]
impl<T: num_traits::Euclid + Copy> Euclid for T {
fn div_euclid(self, rhs: Self) -> Self {
<T as num_traits::Euclid>::div_euclid(&self, &rhs)
Expand Down
8 changes: 4 additions & 4 deletions all-is-cubes-base/src/raycast.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use euclid::Vector3D;

/// Acts as polyfill for float methods
#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use num_traits::float::Float as _;

#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use crate::math::Euclid as _;
use crate::math::{
Axis, Cube, CubeFace, Face7, FreeCoordinate, FreePoint, FreeVector, GridAab, GridCoordinate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ pub(crate) fn parse_universe_source(
mod tests {
use super::*;
use all_is_cubes::euclid::size3;
#[allow(unused_imports)]
use clap::error::{ContextValue, ErrorKind};

fn parse(args: &[&str]) -> clap::error::Result<AicDesktopArgs> {
Expand Down
6 changes: 5 additions & 1 deletion all-is-cubes/src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ struct Key(u64);

impl Key {
fn new() -> Self {
#![allow(clippy::useless_conversion)] // useless on pointer_width=64
#![allow(
clippy::useless_conversion,
clippy::unnecessary_fallible_conversions,
reason = "depends on pointer width and atomic support"
)]

use core::sync::atomic::{self, Ordering};

Expand Down
9 changes: 6 additions & 3 deletions all-is-cubes/src/camera/graphics_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ use crate::{block::Block, space::Space};
// (Due to crate splitting that can't be a doc-link.)
#[doc = include_str!("../save/serde-warning.md")]
#[derive(Clone, Eq, PartialEq)]
#[expect(
clippy::unsafe_derive_deserialize,
reason = "false positive from notnan! macro"
#[cfg_attr(
feature = "save",
expect(
clippy::unsafe_derive_deserialize,
reason = "false positive from notnan! macro"
)
)]
#[cfg_attr(feature = "save", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "save", serde(default))]
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/character/exposure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use euclid::{vec3, Point3D};
use num_traits::float::Float as _;

/// Acts as polyfill for float methods
#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports)]
use crate::math::Euclid as _;

Expand Down
8 changes: 4 additions & 4 deletions all-is-cubes/src/chunking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use std::sync::Mutex;
use euclid::{Point3D, Vector3D};

/// Acts as polyfill for float methods
#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use num_traits::float::FloatCore as _;

#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use crate::math::Euclid as _;
use crate::math::{
Cube, FreeCoordinate, FreePoint, GridAab, GridCoordinate, GridPoint, OctantMask,
Expand Down
5 changes: 3 additions & 2 deletions all-is-cubes/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ pub use all_is_cubes_base::{notnan, rgb_const, rgba_const};
#[doc = include_str!("save/serde-warning.md")]
pub use all_is_cubes_base::math::GridAab;

#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", test)))]
#[allow(dead_code, reason = "unclear why this warns even though it is needed")]
/// Identical to [`num_traits::Euclid`] except that its signatures are compatible with
/// `std` versions.
///
Expand All @@ -38,7 +39,7 @@ pub(crate) trait Euclid {
fn div_euclid(self, rhs: Self) -> Self;
fn rem_euclid(self, rhs: Self) -> Self;
}
#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", test)))]
impl<T: num_traits::Euclid + Copy> Euclid for T {
fn div_euclid(self, rhs: Self) -> Self {
<T as num_traits::Euclid>::div_euclid(&self, &rhs)
Expand Down
8 changes: 4 additions & 4 deletions all-is-cubes/src/physics/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use euclid::Vector3D;
use ordered_float::NotNan;

/// Acts as polyfill for float methods
#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use num_traits::float::Float as _;

use super::collision::{
Expand All @@ -16,8 +16,8 @@ use super::collision::{
use crate::block::{BlockCollision, Resolution};
use crate::camera::Eye;
use crate::fluff::Fluff;
#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use crate::math::Euclid as _;
use crate::math::{Aab, Cube, Face6, Face7, FreeCoordinate, FreePoint, FreeVector, Geometry as _};
use crate::physics::{StopAt, Velocity, POSITION_EPSILON};
Expand Down
14 changes: 10 additions & 4 deletions all-is-cubes/src/raytracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ use core::marker::PhantomData;
use euclid::{vec3, Vector3D};
use manyfmt::Fmt;
/// Acts as polyfill for float methods
#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(
unused_imports,
reason = "unclear why this warns even though it is needed"
)]
use num_traits::float::Float as _;
use ordered_float::NotNan;

Expand All @@ -21,8 +24,11 @@ use rayon::iter::{IntoParallelIterator as _, ParallelIterator as _};
use crate::block::{Evoxels, Resolution, AIR};
use crate::camera::NdcPoint2;
use crate::camera::{Camera, GraphicsOptions, TransparencyOption};
#[cfg(not(feature = "std"))]
#[allow(unused_imports)]
#[cfg(not(any(feature = "std", test)))]
#[allow(
unused_imports,
reason = "unclear why this warns even though it is needed"
)]
use crate::math::Euclid as _;
use crate::math::{
rgb_const, smoothstep, Cube, Face6, Face7, FreeCoordinate, FreePoint, FreeVector, GridAab,
Expand Down
3 changes: 2 additions & 1 deletion all-is-cubes/src/space/light/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use core::fmt;
use euclid::default::Vector3D;

/// Acts as polyfill for float methods
#[cfg(not(feature = "std"))]
#[cfg(not(any(feature = "std", test)))]
#[allow(unused_imports, reason = "unclear why this warns even though it is needed")]
use num_traits::float::Float as _;

use crate::math::{NotNan, Rgb};
Expand Down
6 changes: 5 additions & 1 deletion all-is-cubes/src/universe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ cfg_if::cfg_if! {

impl UniverseId {
fn new() -> Self {
#![allow(clippy::useless_conversion, reason = "useless on pointer_width=64")]
#![allow(
clippy::useless_conversion,
clippy::unnecessary_fallible_conversions,
reason = "depends on pointer width and atomic support"
)]

let id = UNIVERSE_ID_COUNTER
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |counter| {
Expand Down

0 comments on commit 1c7375f

Please sign in to comment.