Skip to content

Commit

Permalink
Rust 1.81: Convert comments on lint attributes to lint reasons.
Browse files Browse the repository at this point in the history
This is based on a regex search, so some comments may have been missed.
Some TODO comments have been left, as they did not fit well as reasons.
  • Loading branch information
kpreid committed Sep 5, 2024
1 parent ed0a060 commit 2ab7638
Show file tree
Hide file tree
Showing 62 changed files with 176 additions and 105 deletions.
5 changes: 4 additions & 1 deletion all-is-cubes-base/src/math/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,10 @@ pub struct FaceMap<V> {
pub pz: V,
}

#[allow(clippy::missing_inline_in_public_items)] // all methods are generic code
#[allow(
clippy::missing_inline_in_public_items,
reason = "all methods are generic code"
)]
impl<V> FaceMap<V> {
/// Constructs a [`FaceMap`] by using the provided function to compute
/// a value for each [`Face6`] enum variant.
Expand Down
14 changes: 7 additions & 7 deletions all-is-cubes-base/src/math/grid_aab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::math::{
use crate::resolution::Resolution;
use crate::util::ConciseDebug;

#[allow(missing_docs)] // documented in its all-is-cubes reexport
#[allow(missing_docs, reason = "documented in its all-is-cubes reexport")]
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub struct GridAab {
lower_bounds: GridPoint,
Expand Down Expand Up @@ -83,7 +83,7 @@ impl GridAab {
// and other such alternate numeric types. There would be no disadvantage since this is a
// range-checked operation anyway. However, we'd need a custom conversion trait to handle that.
#[track_caller]
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn from_lower_size(lower_bounds: impl Into<GridPoint>, sizes: impl Into<GridSize>) -> Self {
Self::checked_from_lower_size(lower_bounds.into(), sizes.into())
.expect("GridAab::from_lower_size")
Expand All @@ -97,7 +97,7 @@ impl GridAab {
/// rather than discrete coordinates) spans 5 to 10.
///
/// Returns [`Err`] if any of the `upper_bounds` are less than the `lower_bounds`.
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn checked_from_lower_upper(
lower_bounds: impl Into<GridPoint>,
upper_bounds: impl Into<GridPoint>,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl GridAab {
///
/// Panics if any of the `upper_bounds` are less than the `lower_bounds`.
#[track_caller]
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn from_lower_upper(
lower_bounds: impl Into<GridPoint>,
upper_bounds: impl Into<GridPoint>,
Expand All @@ -149,7 +149,7 @@ impl GridAab {
/// Constructs a [`GridAab`] from [`Range`]s.
///
/// This is identical to [`GridAab::from_lower_upper()`] except for the input type.
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
#[track_caller]
pub fn from_ranges(ranges: impl Into<Vector3D<Range<GridCoordinate>, Cube>>) -> GridAab {
let ranges = ranges.into();
Expand All @@ -163,7 +163,7 @@ impl GridAab {
///
/// Returns [`Err`] if the `size` is negative or adding it to `lower_bounds` overflows.
#[track_caller]
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn checked_from_lower_size(
lower_bounds: impl Into<GridPoint>,
size: impl Into<GridSize>,
Expand Down Expand Up @@ -670,7 +670,7 @@ impl GridAab {
/// );
/// ```
#[must_use]
#[allow(clippy::missing_inline_in_public_items)] // already generic
#[allow(clippy::missing_inline_in_public_items, reason = "already generic")]
pub fn translate(&self, offset: impl Into<GridVector>) -> Self {
fn inner(this: &GridAab, offset: GridVector) -> GridAab {
let offset = offset.to_point();
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-base/src/math/grid_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Iterator for GridIter {
Some(result.into())
}

#[allow(clippy::missing_inline_in_public_items)] // unclear benefit
#[allow(clippy::missing_inline_in_public_items, reason = "unclear benefit")]
fn size_hint(&self) -> (usize, Option<usize>) {
match usize::try_from((self.x_range.end - self.cube.x) - 1) {
Err(_) => {
Expand All @@ -105,7 +105,7 @@ impl Iterator for GridIter {
}

// Override fold() to achieve greater performance via simpler iteration.
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
fn fold<B, F>(mut self, init: B, mut f: F) -> B
where
F: FnMut(B, Self::Item) -> B,
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-base/src/math/rotation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! Rotations which exchange axes (thus not leaving the integer grid).
//! This module is private but reexported by its parent.
#![allow(clippy::large_stack_arrays)] // effectively-false positive on Arbitrary derive
#![allow(
clippy::large_stack_arrays,
reason = "effectively-false positive on Arbitrary derive"
)]

use core::marker::PhantomData;
use core::ops::Mul;
Expand Down
16 changes: 8 additions & 8 deletions all-is-cubes-base/src/math/vol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<O> Vol<(), O> {
///
/// Returns a [`VolLengthError`] if the number of elements does not match
/// [`bounds.volume()`](GridAab::volume).
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn with_elements<C, V>(self, elements: C) -> Result<Vol<C, O>, VolLengthError>
where
C: Deref<Target = [V]>,
Expand Down Expand Up @@ -120,7 +120,7 @@ where
/// [`bounds.volume()`](GridAab::volume).
//---
// TODO: Remove this in favor of with_elements()?
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn from_elements(bounds: GridAab, elements: impl Into<C>) -> Result<Self, VolLengthError> {
let elements = elements.into();
if Some(elements.len()) == bounds.volume() {
Expand All @@ -141,7 +141,7 @@ where
/// Constructors from elements.
//---
// TODO: This should be `O: Ordering` instead of `ZMaj` once we have alternative orderings
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
impl<C, V> Vol<C, ZMaj>
where
// Note that the Deref bound is necessary to give this a unique `V`.
Expand Down Expand Up @@ -372,7 +372,7 @@ impl<C> Vol<C, ZMaj> {
}

/// Linear data access.
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
impl<C, O, V> Vol<C, O>
where
C: Deref<Target = [V]>,
Expand Down Expand Up @@ -482,7 +482,7 @@ impl<V: Clone, O> Vol<Arc<[V]>, O> {
}

/// Element lookup operations by 3D coordinates.
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
impl<C, V> Vol<C, ZMaj>
where
C: Deref<Target = [V]>,
Expand Down Expand Up @@ -526,7 +526,7 @@ where
}
}

#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
impl<V, O> Vol<Box<[V]>, O> {
/// Apply `f` to each element and collect the results into the same shape and ordering.
pub fn map<T, F>(self, f: F) -> Vol<Box<[T]>, O>
Expand All @@ -544,7 +544,7 @@ impl<V, O> Vol<Box<[V]>, O> {
}
}

#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
impl<C: fmt::Debug, O: fmt::Debug> fmt::Debug for Vol<C, O> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Note: If specialization was available we'd like to use it to print the elements under
Expand Down Expand Up @@ -785,7 +785,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)] // known to fit
#[allow(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.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Raycaster {
/// assert_eq!(next().cube_ahead(), Cube::new(2, 1, 0));
/// ```
#[must_use]
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn new(origin: impl Into<FreePoint>, direction: impl Into<FreeVector>) -> Self {
Self::new_impl(origin.into(), direction.into())
}
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 @@ -50,7 +50,7 @@ impl Ray {
/// }
/// );
/// ```
#[allow(clippy::missing_inline_in_public_items)] // is generic already
#[allow(clippy::missing_inline_in_public_items, reason = "is generic already")]
pub fn new(origin: impl Into<FreePoint>, direction: impl Into<FreeVector>) -> Self {
Self {
origin: origin.into(),
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-content/src/atrium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@ async fn install_atrium_blocks(

// TODO: This whole section is about having noise pick from a fixed set of pregenerated shades.
// We should abstract it out if we like this style
#[allow(clippy::cast_lossless)] // warns on 32-bit but f64::from() is not an option on 64-bit
#[allow(
clippy::cast_lossless,
reason = "warns on 32-bit but f64::from() is not an option on 64-bit"
)]
let stone_range: Vec<Block> = (-2..=2_isize)
.map(|x| scale_color(stone_base.clone(), 1.0 + x as f64 * 0.08, 0.02))
.collect();
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 @@ -26,7 +26,6 @@ pub(crate) struct Context<'a> {
#[derive(Clone, Copy, Debug)]
pub(crate) enum Placement {
Surface,
#[allow(unused)] // TODO: polish this and then use it
Underground,
}

Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/template.rs
Original file line number Diff line number Diff line change
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)] // big numbers will break anyway
#[allow(clippy::cast_possible_wrap, reason = "big numbers will break anyway")]
let bounds = GridAab::checked_from_lower_size(
[
-((size.width / 2) as i32),
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-content/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ 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(unnameable_types)] // TODO: this should be public with an opaque struct wrapper
#[allow(
unnameable_types,
reason = "TODO: this should be public with an opaque struct wrapper"
)]
pub enum TreeGrowth {
Sapling = 1, // radius = 1
G2, // radius = 2
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-desktop/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use crate::Session;

/// Fills the audio slot in a `DesktopSession` to actually produce audio.
pub(crate) struct AudioOut {
#[allow(dead_code)] // eventually we're going to need this for volume control etc.
#[allow(
dead_code,
reason = "eventually we're going to need this for volume control etc."
)]
sender: mpsc::SyncSender<AudioCommand>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl AicDesktopArgs {
///
/// Panics if `output_path` is not validated (this should have been checked at parse time).
#[cfg(feature = "record")]
#[allow(clippy::unnecessary_wraps)] // *currently* no error can happen
#[allow(clippy::unnecessary_wraps, reason = "*currently* no error can happen")]
pub fn record_options(&self) -> Result<Option<RecordOptions>, anyhow::Error> {
let Some((output_path, output_format)) = self.output_file_and_format.clone() else {
return Ok(None);
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-desktop/src/bin/all-is-cubes/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};

use anyhow::Context;
#[allow(unused)] // may be unused with some features
#[allow(unused, reason = "may be unused with some features")]
use clap::{CommandFactory as _, Parser as _};

use all_is_cubes::euclid::Size2D;
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-desktop/src/record/write_png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use all_is_cubes_render::Rendering;
use crate::record::{RecordOptions, Status};

/// Occupy a thread with writing a sequence of frames as (A)PNG data.
#[allow(clippy::needless_pass_by_value)] // let thread function own its state
#[allow(
clippy::needless_pass_by_value,
reason = "let thread function own its state"
)]
pub(crate) fn threaded_write_frames(
file: File,
options: RecordOptions,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-desktop/src/terminal/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl TerminalWindow {
}

fn update(&mut self) {
#[allow(clippy::while_let_loop)] // this is clearer about its behavior
#[allow(clippy::while_let_loop, reason = "this is clearer about its behavior")]
loop {
match self.in_receiver.try_recv() {
Ok(InMsg::Viewport(v)) => self.viewport_position = v,
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-gpu/src/common/octree_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ impl<A> Alloctree<A> {
///
/// If the handle does not exactly match a previous allocation from this allocator,
/// may panic or deallocate something else.
#[allow(clippy::needless_pass_by_value)] // deliberately taking handle ownership
#[allow(
clippy::needless_pass_by_value,
reason = "deliberately taking handle ownership"
)]
pub fn free(&mut self, handle: AlloctreeHandle<A>) {
self.root.free(self.size_exponent, handle.allocation.min);
self.occupied_volume -= handle.allocation.map(usize::from).volume();
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-gpu/src/in_wgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,10 @@ impl<I: time::Instant> EverythingRenderer<I> {
info_text_texture.upload(queue);
}

#[allow(clippy::let_and_return)] // <https://github.com/rust-lang/rust-clippy/issues/9150>
#[allow(
clippy::let_and_return,
reason = "<https://github.com/rust-lang/rust-clippy/issues/9150>"
)]
let flaws = postprocess::postprocess(self, queue, output);

#[cfg(feature = "rerun")]
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-gpu/src/in_wgpu/block_texture.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Block texture atlas management: provides [`AtlasAllocator`], the
//! [`texture::Allocator`] implementation for use with [`wgpu`].
#![allow(clippy::arc_with_non_send_sync)] // wgpu on wasm
#![allow(clippy::arc_with_non_send_sync, reason = "wgpu on wasm")]

use std::sync::{Arc, Mutex, MutexGuard, Weak};

Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-gpu/src/in_wgpu/frame_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ impl FramebufferTextures {
self.config.enable_copy_out
}

#[allow(unused)] // Used only in special cases such as cfg(test) and cfg(feature = "rerun")
#[allow(
unused,
reason = "Used only in special cases such as cfg(test) and cfg(feature = \"rerun\")"
)]
pub(crate) fn scene_for_test_copy(&self) -> &wgpu::Texture {
debug_assert!(self.config.enable_copy_out);
if let Some(resolved) = &self.linear_scene_resolved_tex {
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-gpu/src/in_wgpu/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ pub fn to_wgpu_color(color: Rgba) -> wgpu::Color {
}
}

#[allow(clippy::needless_pass_by_value)] // the value is nearly a reference itself
#[allow(
clippy::needless_pass_by_value,
reason = "the value is nearly a reference itself"
)]
pub fn to_wgpu_index_format(slice: IndexSlice<'_>) -> wgpu::IndexFormat {
match slice {
IndexSlice::U16(_) => wgpu::IndexFormat::Uint16,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-gpu/src/in_wgpu/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub async fn try_create_adapter_for_test(
adapter
}

#[allow(dead_code)] // conditionally used
#[allow(dead_code, reason = "conditionally used")]
fn shortened_adapter_info(info: &wgpu::AdapterInfo) -> String {
// Make the string more concise by deleting empty-valued fields.
// TODO: maybe just destructure and do our own formatting
Expand Down
7 changes: 5 additions & 2 deletions all-is-cubes-gpu/src/in_wgpu/raytrace_to_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl Inner {

let render_viewport = self.render_viewport;

#[allow(clippy::needless_collect)] // needed with rayon and not without
#[allow(clippy::needless_collect, reason = "needed with rayon and not without")]
let this_frame_pixels: Vec<Point> = (0..self.rays_per_frame)
.map(|_i| self.pixel_picker.next().unwrap())
.collect();
Expand Down Expand Up @@ -212,7 +212,10 @@ impl Inner {

#[cfg(feature = "auto-threads")]
/// Runs raytracing, periodically releasing the lock to allow updating input and retrieving output.
#[allow(clippy::needless_pass_by_value)] // let thread function own its state
#[allow(
clippy::needless_pass_by_value,
reason = "let thread function own its state"
)]
fn background_tracing_task(weak_inner: Weak<Mutex<Inner>>) {
// By using a weak reference, we arrange for this task to stop itself when it is no longer
// relevant.
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-gpu/src/in_wgpu/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,10 @@ fn set_buffers<'a>(render_pass: &mut wgpu::RenderPass<'a>, buffers: &'a ChunkBuf
}

/// Copy [`SpaceMesh`] data to GPU buffers.
#[allow(clippy::needless_pass_by_value)] // https://github.com/rust-lang/rust-clippy/issues/12525
#[allow(
clippy::needless_pass_by_value,
reason = "https://github.com/rust-lang/rust-clippy/issues/12525"
)]
fn update_chunk_buffers<I: time::Instant>(
mut bwp: BeltWritingParts<'_, '_>,
update: RenderDataUpdate<'_, WgpuMt<I>>,
Expand Down
5 changes: 4 additions & 1 deletion all-is-cubes-mesh/src/dynamic/chunked_mesh/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ fn todo_ignores_absent_chunks() {

#[derive(Debug)]
struct CsmTester<const MBM: usize> {
#[allow(dead_code)] // Universe must be kept alive but is not read after construction
#[allow(
dead_code,
reason = "Universe must be kept alive but is not read after construction"
)]
universe: Universe,
space: Handle<Space>,
camera: Camera,
Expand Down
Loading

0 comments on commit 2ab7638

Please sign in to comment.