Skip to content

Commit

Permalink
Rust 1.81: Use #[expect] instead of #[allow] for expected lint.
Browse files Browse the repository at this point in the history
Also delete no-longer-needed `#[allow]`s.

Have not converted `missing_docs` and `clippy::missing_inline_in_public_items`
due to false positives.
  • Loading branch information
kpreid committed Sep 13, 2024
1 parent 47e57e8 commit aa70336
Show file tree
Hide file tree
Showing 132 changed files with 201 additions and 258 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"), allow(clippy::arc_with_non_send_sync))]
#![cfg_attr(not(feature = "std"), expect(clippy::arc_with_non_send_sync))]
#![warn(clippy::missing_inline_in_public_items)]

#[cfg(any(feature = "std", test))]
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub trait Geometry {
///
/// The primary way in which these are used is [`Geometry::wireframe_points()`].
#[derive(Clone, Copy, Debug, PartialEq)]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct LineVertex {
/// Position of the vertex.
pub position: FreePoint,
Expand Down
1 change: 0 additions & 1 deletion all-is-cubes-base/src/math/aab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ impl Geometry for Aab {
where
E: Extend<LineVertex>,
{
#[allow(clippy::large_stack_arrays)]
let mut vertices = [LineVertex::from(FreePoint::origin()); 24];
let l = self.lower_bounds_p();
let u = self.upper_bounds_p();
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/math/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::math::{Face6, Rgb};
/// See also:
///
/// * [`Face6`] specifies an axis and a direction on the axis.
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, exhaust::Exhaust)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
// do after tests:#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-base/src/math/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct Rgba {
/// Unit-of-measure type for vectors that contain color channels.
//---
// TODO(euclid migration): Better name?
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[derive(Debug, Eq, PartialEq)]
pub enum Intensity {}

Expand Down Expand Up @@ -669,7 +669,7 @@ const fn component_from_srgb8_const(c: u8) -> NotNan<f32> {
/// frame.
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[repr(u8)]
pub enum OpacityCategory {
/// Alpha of zero; completely transparent; completely invisible; need not be drawn.
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/math/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Cube {
/// Apply a function to each coordinate independently.
///
/// If a different return type is desired, use `.lower_bounds().map(f)` instead.
#[allow(clippy::return_self_not_must_use)]
#[expect(clippy::return_self_not_must_use)]
#[inline]
pub fn map(self, mut f: impl FnMut(GridCoordinate) -> GridCoordinate) -> Self {
Self {
Expand Down
17 changes: 9 additions & 8 deletions all-is-cubes-base/src/math/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use crate::math::{
/// variant. The two enums use the same discriminant numbering.
///
#[doc = include_str!("../serde-warning.md")]
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, exhaust::Exhaust)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand All @@ -52,8 +51,7 @@ pub enum Face6 {
/// provided. The two enums use the same discriminant numbering.
///
#[doc = include_str!("../serde-warning.md")]
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, exhaust::Exhaust)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -108,7 +106,10 @@ impl Face6 {
/// * If all magnitudes are zero, the Z axis's sign is used. (Remember that floating-point
/// numbers include distinct positive and negative zeroes).
/// * If any coordinate is NaN, returns [`None`].
#[allow(unused)] // TODO: I expect to use this in block placement
#[cfg_attr(
not(test),
expect(dead_code, reason = "TODO: I expect to use this in block placement")
)]
fn from_snapped_vector(vector: FreeVector) -> Option<Self> {
let Vector3D { x, y, z, _unit } = vector;

Expand Down Expand Up @@ -589,7 +590,7 @@ impl TryFrom<GridVector> for Face7 {
/// is needed, such as converting to a [`Face6`].
#[derive(Copy, Clone, Debug, Eq, PartialEq, displaydoc::Display)]
#[displaydoc("Face7::Within does not have a direction or axis")]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct Faceless;

#[cfg(feature = "rerun")]
Expand Down Expand Up @@ -627,7 +628,7 @@ impl From<Face6> for re_types::view_coordinates::SignedAxis3 {
}

/// Container for values keyed by [`Face6`]s. Always holds exactly six elements.
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
#[derive(Clone, Copy, Default, Hash, PartialEq, Eq, exhaust::Exhaust)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct FaceMap<V> {
Expand Down Expand Up @@ -919,7 +920,7 @@ impl_binary_operator_for_facemap!(Rem::rem);
/// The combination of a [`Cube`] and [`Face7`] identifying one face of it or the interior.
/// This pattern appears in cursor selection and collision detection.
#[derive(Clone, Copy, Hash, Eq, PartialEq)]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
#[allow(missing_docs)]
pub struct CubeFace {
pub cube: Cube,
Expand Down
9 changes: 4 additions & 5 deletions all-is-cubes-base/src/math/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::math::{
/// TODO: The operators implemented for this are very incomplete.
///
/// TODO(euclid migration): Can we dispose of this type now?
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct GridMatrix {
/// First column
Expand Down Expand Up @@ -55,7 +55,7 @@ impl GridMatrix {

/// Note: This takes the elements in a column-major ordering, so the argument order
/// is transposed relative to a conventional textual display of a matrix.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
#[inline]
pub const fn new(
x0: GridCoordinate,
Expand Down Expand Up @@ -297,7 +297,7 @@ impl GridMatrix {
const INVERSE_EPSILON: FreeCoordinate = 0.25 / (GridCoordinate::MAX as FreeCoordinate);
fn try_round(v: [FreeCoordinate; 4], expected_w: FreeCoordinate) -> Option<GridVector> {
let mut result = Vector3D::zero();
#[allow(clippy::needless_range_loop)]
#[expect(clippy::needless_range_loop)]
for axis in 0..4 {
let rounded = v[axis].round();
let remainder = v[axis] - rounded;
Expand All @@ -312,7 +312,7 @@ impl GridMatrix {
2 => result.z = rounded as GridCoordinate,
3 =>
{
#[allow(clippy::float_cmp)]
#[expect(clippy::float_cmp)]
if rounded != expected_w {
return None;
}
Expand All @@ -334,7 +334,6 @@ impl GridMatrix {
}

/// Mini 4D vector for matrix rows.
#[allow(clippy::exhaustive_structs)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
struct MVector4<T> {
x: T,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/math/octant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::math::{Cube, Face6, FreeVector, GridCoordinate, GridPoint};
/// This enum's discriminants are not currently to be considered stable; they may be reordered.
//---
// TODO: Replace this with an enum.
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[derive(Clone, Copy, Eq, Hash, PartialEq, exhaust::Exhaust)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[repr(u8)]
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/math/rigid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::math::{GridAab, GridCoordinate};
/// These transformations are always invertible except in the case of numeric overflow.
///
/// [rigid transformation]: https://en.wikipedia.org/wiki/Rigid_transformation
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Gridgid {
/// Rotation component. Applied before the translation.
Expand Down
3 changes: 1 addition & 2 deletions all-is-cubes-base/src/math/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ use crate::math::GridAab;
///
#[doc = include_str!("../serde-warning.md")]
#[rustfmt::skip]
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::exhaustive_enums)]
#[expect(clippy::exhaustive_enums)]
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down
6 changes: 3 additions & 3 deletions all-is-cubes-base/src/math/vol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::math::{Axis, Cube, GridAab, GridCoordinate, GridIter, GridPoint, Grid
///
/// Use this type with [`Vol`] to store volume data in this order.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct ZMaj;

/// Type for volume data stored in a slice, or for generating linear indexing.
Expand Down Expand Up @@ -191,7 +191,7 @@ where
// TODO: Reimplement this in terms of adopting the elements as a linear array.
// TODO: Test.
#[doc(hidden)] // used by all-is-cubes-content
#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
pub fn from_y_flipped_array<const DX: usize, const DY: usize, const DZ: usize>(
array: [[[V; DX]; DY]; DZ],
) -> Self
Expand Down Expand Up @@ -782,7 +782,7 @@ fn find_zmaj_subdivision(bounds: GridAab) -> Option<(GridAab, GridAab, usize)> {
let axis_range = bounds.axis_range(axis);
let size: u32 = bounds.size()[axis];
if size >= 2 {
#[allow(clippy::cast_possible_wrap, reason = "known to fit")]
#[expect(clippy::cast_possible_wrap, reason = "known to fit")]
let split_coordinate = axis_range.start + (size / 2) as i32;

let mut lower_half_ub = bounds.upper_bounds();
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/raycast/ray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::math::GridAab;

/// A ray; a half-infinite line segment (sometimes used as finite by the length of the
/// direction vector).
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Ray {
// TODO(euclid migration): should we expose the coordinate unit generic?
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Instant for std::time::Instant {
/// is available **and it's okay for all time measurements to be recorded as zero**.
#[doc(hidden)]
#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct NoTime;

impl Instant for NoTime {
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod error_chain {
/// which interferes with this one for [`Error`].
#[doc(hidden)] // not something we wish to be stable public API
#[derive(Clone, Copy, Debug)]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct ErrorChain<'a>(pub &'a (dyn Error + 'a));

impl fmt::Display for ErrorChain<'_> {
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-base/src/util/custom_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use manyfmt::{Fmt, Refmt as _};
/// The value is a `PhantomData` to avoid requiring an actual instance of the type.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[doc(hidden)] // too specific to be good public API ... arguably should be part of refmt itself.
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct TypeName;
impl<T> Fmt<TypeName> for PhantomData<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>, _: &TypeName) -> fmt::Result {
Expand All @@ -23,7 +23,7 @@ impl<T> Fmt<TypeName> for PhantomData<T> {
///
/// This format may be on one line despite the pretty-printing option, and may lose
/// precision or Rust syntax in favor of a short at-a-glance representation.
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct ConciseDebug;

Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/alg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub(crate) fn space_to_space_copy(
}

/// As [`space_to_space_copy`], but producing a transaction.
#[allow(dead_code)] // TODO: currently unused but will probably come up again...?
#[expect(dead_code)] // TODO: currently unused but will probably come up again...?
pub(crate) fn space_to_transaction_copy(
src: &Space,
src_bounds: GridAab,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub(crate) struct Fire {
blocks: [Block; 4],
/// The bounds of this array determine the affected blocks.
// TODO: should be using the attachment bounds instead of internally stored bounds
#[allow(clippy::struct_field_names)]
#[expect(clippy::struct_field_names)]
fire_state: Vol<Box<[u8]>>,
rng: Xoshiro256Plus,
/// Time accumulation not yet equal to a whole frame.
Expand Down
1 change: 0 additions & 1 deletion all-is-cubes-content/src/atrium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ fn map_text_block(
}
}

#[allow(clippy::too_many_arguments)]
fn arch_row(
space: &mut Space,
blocks: &BlockProvider<AtriumBlocks>,
Expand Down
1 change: 0 additions & 1 deletion all-is-cubes-content/src/city/exhibit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use all_is_cubes_ui::vui::widgets;

use crate::city::CityPlanner;

#[allow(clippy::type_complexity)]
pub(crate) struct Exhibit {
pub name: &'static str,
pub subtitle: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/dungeon/demo_dungeon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused_qualifications)] // macro false positive
#![expect(unused_qualifications)] // macro false positive

use core::f64::consts::TAU;
use core::mem;
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/dungeon/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl DungeonGrid {
}

/// Returns the volume which lies between two rooms and meets their adjoining faces.
#[allow(dead_code)] // TODO: superseded in use by theme-specific sizes; review if should keep
#[expect(dead_code)] // TODO: superseded in use by theme-specific sizes; review if should keep
pub fn shared_wall_at(&self, room_position: Cube, face: Face6) -> GridAab {
self.room_box_at(room_position)
.abut(
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub async fn template_menu_space(
Ok(space)
}

#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
fn template_menu_widget_tree(
widget_theme: &widgets::WidgetTheme,
action: Arc<dyn Fn(&UniverseTemplate) + Send + Sync>,
Expand Down
6 changes: 3 additions & 3 deletions all-is-cubes-content/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn insert_generated_space(
///
/// Pass this structure to [`UniverseTemplate::build()`].
#[derive(Clone, Debug, Default, Eq, PartialEq)]
#[allow(clippy::exhaustive_structs)]
#[expect(clippy::exhaustive_structs)]
pub struct TemplateParameters {
/// Seed for any randomization which the template performs.
/// Not all templates have random elements.
Expand Down Expand Up @@ -324,7 +324,7 @@ async fn islands(
let size = size.unwrap_or(GridSize::new(1000, 400, 1000));

// Set up dimensions
#[allow(clippy::cast_possible_wrap, reason = "big numbers will break anyway")]
#[expect(clippy::cast_possible_wrap, reason = "big numbers will break anyway")]
let bounds = GridAab::checked_from_lower_size(
[
-((size.width / 2) as i32),
Expand Down Expand Up @@ -494,7 +494,7 @@ mod tests {
use all_is_cubes::util::yield_progress_for_testing;
use futures_core::future::BoxFuture;

#[allow(clippy::let_underscore_future)]
#[expect(clippy::let_underscore_future)]
fn _test_build_future_is_send() {
let _: BoxFuture<'_, _> = Box::pin(UniverseTemplate::Atrium.build::<std::time::Instant>(
yield_progress_for_testing(),
Expand Down
5 changes: 2 additions & 3 deletions all-is-cubes-content/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use crate::LandscapeBlocks::{self, Leaves, Log};
///
/// TODO: make the public version of this a struct with private contents
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, exhaust::Exhaust)]
#[allow(clippy::exhaustive_enums)]
#[allow(
#[expect(
unnameable_types,
reason = "TODO: this should be public with an opaque struct wrapper"
)]
Expand Down Expand Up @@ -214,7 +213,7 @@ pub(crate) fn make_tree(

use graph::Growph;
mod graph {
#![allow(clippy::option_option)]
#![expect(clippy::option_option)]

use super::*;
use all_is_cubes::euclid::default::Vector3D;
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-desktop/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::Session;

/// Fills the audio slot in a `DesktopSession` to actually produce audio.
pub(crate) struct AudioOut {
#[allow(
#[expect(
dead_code,
reason = "eventually we're going to need this for volume control etc."
)]
Expand Down Expand Up @@ -53,7 +53,7 @@ pub(crate) fn init_sound(session: &Session) -> Result<AudioOut, anyhow::Error> {
}

/// Thread function for receiving commands and executing them on `&mut AudioManager`.
#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
fn audio_command_thread(receiver: mpsc::Receiver<AudioCommand>, mut manager: AudioManager) {
// TODO: better sound and more sounds
let beep = StaticSoundData {
Expand Down
1 change: 0 additions & 1 deletion all-is-cubes-desktop/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub(crate) struct Recorder {
}

// TODO: should this be a trait? It's also an awful lot like HeadlessRenderer, except without the image output...
#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
enum RecorderInner {
Shutdown,
Expand Down
Loading

0 comments on commit aa70336

Please sign in to comment.