Skip to content

Commit

Permalink
Add #![warn(unused_qualifications)].
Browse files Browse the repository at this point in the history
This lint will help me write code with fewer pointless inconsistencies.
  • Loading branch information
kpreid committed Oct 31, 2023
1 parent 5f69a80 commit 4f5c129
Show file tree
Hide file tree
Showing 45 changed files with 143 additions and 149 deletions.
2 changes: 1 addition & 1 deletion all-is-cubes-content/src/city.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ async fn place_exhibits_in_city<I: Instant>(
.unwrap();

let walkway = entrance_plane.abut(Face6::NY, 1).unwrap();
space.fill_uniform(walkway, &demo_blocks[DemoBlocks::Road])?;
space.fill_uniform(walkway, &demo_blocks[Road])?;

let walking_volume = entrance_plane.abut(Face6::PY, 2).unwrap();
space.fill_uniform(walking_volume, &AIR)?;
Expand Down
20 changes: 7 additions & 13 deletions all-is-cubes-content/src/dungeon/demo_dungeon.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused_qualifications)] // macro false positive

use core::f64::consts::TAU;
use core::mem;

Expand Down Expand Up @@ -183,15 +185,11 @@ impl DemoTheme {
let gate_side_2 = gate_box.abut(wall_parallel, -1).unwrap();
space.fill_uniform(
gate_side_2,
&self.blocks[DungeonBlocks::Gate]
.clone()
.rotate(rotate_nz_to_face),
&self.blocks[Gate].clone().rotate(rotate_nz_to_face),
)?;
space.fill_uniform(
gate_side_1,
&self.blocks[DungeonBlocks::GatePocket]
.clone()
.rotate(rotate_nz_to_face),
&self.blocks[GatePocket].clone().rotate(rotate_nz_to_face),
)?;
// TODO: add opening/closing mechanism and make some of these outright blocked
}
Expand Down Expand Up @@ -266,13 +264,13 @@ impl Theme<Option<DemoRoom>> for DemoTheme {
assert!(!room_data.corridor_only, "{room_data:?}");
space.fill_uniform(
interior.abut(Face6::NY, -1).unwrap(),
&self.blocks[DungeonBlocks::Spikes],
&self.blocks[Spikes],
)?;
}

match room_data.floor {
FloorKind::Solid => {
space.fill_uniform(floor_layer, &self.blocks[DungeonBlocks::FloorTile])?;
space.fill_uniform(floor_layer, &self.blocks[FloorTile])?;
}
FloorKind::Chasm => { /* TODO: little platforms */ }
FloorKind::Bridge => {
Expand All @@ -286,10 +284,7 @@ impl Theme<Option<DemoRoom>> for DemoTheme {
let bridge_box = GridAab::single_cube(midpoint)
.union(GridAab::single_cube(wall_cube))
.unwrap();
space.fill_uniform(
bridge_box,
&self.blocks[DungeonBlocks::FloorTile],
)?;
space.fill_uniform(bridge_box, &self.blocks[FloorTile])?;
}
}
}
Expand Down Expand Up @@ -640,7 +635,6 @@ pub async fn install_dungeon_blocks(
.build();
let spike_metal = Block::from(palette::STEEL);

use DungeonBlocks::*;
BlockProvider::<DungeonBlocks>::new(progress, |key| {
Ok(match key {
CorridorLight => Block::builder()
Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-content/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
15 changes: 6 additions & 9 deletions all-is-cubes-content/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ use all_is_cubes::{
universe::Universe,
};
use all_is_cubes_ui::logo::logo_text;
use all_is_cubes_ui::vui::{
self, install_widgets, widgets, Align, LayoutGrant, LayoutRequest, LayoutTree, Layoutable,
WidgetController,
};
use all_is_cubes_ui::vui::{self, install_widgets, widgets, Align, LayoutTree, Layoutable as _};

use crate::UniverseTemplate;

Expand Down Expand Up @@ -76,13 +73,13 @@ impl TemplateButton {

impl vui::Layoutable for TemplateButton {
fn requirements(&self) -> vui::LayoutRequest {
LayoutRequest {
vui::LayoutRequest {
minimum: GridVector::new(10, 1, 2),
}
}
}
impl vui::Widget for TemplateButton {
fn controller(self: Arc<Self>, position: &vui::LayoutGrant) -> Box<dyn WidgetController> {
fn controller(self: Arc<Self>, position: &vui::LayoutGrant) -> Box<dyn vui::WidgetController> {
Box::new(TemplateButtonController {
definition: self,
position: *position,
Expand All @@ -93,7 +90,7 @@ impl vui::Widget for TemplateButton {
#[derive(Debug)]
struct TemplateButtonController {
definition: Arc<TemplateButton>,
position: LayoutGrant,
position: vui::LayoutGrant,
}
impl vui::WidgetController for TemplateButtonController {
fn initialize(&mut self) -> Result<vui::WidgetTransaction, vui::InstallVuiError> {
Expand Down Expand Up @@ -146,7 +143,7 @@ pub(crate) fn template_menu(universe: &mut Universe) -> Result<Space, InGenError
let mut vertical_widgets: Vec<vui::WidgetTree> = Vec::with_capacity(10);
vertical_widgets.push(LayoutTree::leaf(Arc::new(logo_widget)));
for template in template_iter {
vertical_widgets.push(LayoutTree::spacer(LayoutRequest {
vertical_widgets.push(LayoutTree::spacer(vui::LayoutRequest {
minimum: GridVector::new(1, 1, 1),
}));
vertical_widgets.push(LayoutTree::leaf(Arc::new(TemplateButton::new(
Expand Down Expand Up @@ -192,7 +189,7 @@ pub(crate) fn template_menu(universe: &mut Universe) -> Result<Space, InGenError
})
.build();

install_widgets(LayoutGrant::new(bounds), &tree)?
install_widgets(vui::LayoutGrant::new(bounds), &tree)?
.execute(&mut space, &mut transaction::no_outputs)?;

Ok(space)
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-desktop/src/aic_winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::session::DesktopSession;
pub(crate) struct WinAndState {
/// The underlying window.
/// Safety requirement: This is never overwritten.
window: winit::window::Window,
window: Window,

/// The last [`winit::WindowEvent::Occluded`] event we received.
/// Winit gives us no way to query this so we have to remember it.
Expand All @@ -41,7 +41,7 @@ pub(crate) struct WinAndState {
mouse_position: Option<winit::dpi::PhysicalPosition<f64>>,

/// The last cursor grab state we set.
cursor_grab_mode: winit::window::CursorGrabMode,
cursor_grab_mode: CursorGrabMode,

ignore_next_mouse_move: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-desktop/src/command_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ mod tests {
fn error_context(
error: &clap::Error,
wanted_kind: clap::error::ContextKind,
) -> Option<&clap::error::ContextValue> {
) -> Option<&ContextValue> {
error
.context()
.find_map(|(k, v)| if k == wanted_kind { Some(v) } else { None })
Expand Down
7 changes: 4 additions & 3 deletions all-is-cubes-desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down Expand Up @@ -71,7 +72,7 @@ use crate::terminal::{
create_terminal_session, terminal_main_loop, terminal_print_once, TerminalOptions,
};

type Session = all_is_cubes_ui::apps::Session<std::time::Instant>;
type Session = all_is_cubes_ui::apps::Session<Instant>;

// TODO: put version numbers in the title when used as a window title
static TITLE: &str = "All is Cubes";
Expand Down Expand Up @@ -410,7 +411,7 @@ async fn create_universe(
});
template
.clone()
.build::<std::time::Instant>(
.build::<Instant>(
yield_progress,
TemplateParameters {
seed: Some(seed),
Expand Down Expand Up @@ -509,7 +510,7 @@ fn evaluate_light_with_progress(space: &mut Space) {
let light_progress = ProgressBar::new(100)
.with_style(common_progress_style())
.with_prefix("Lighting");
space.evaluate_light::<std::time::Instant>(1, lighting_progress_adapter(&light_progress));
space.evaluate_light::<Instant>(1, lighting_progress_adapter(&light_progress));
light_progress.finish();
}

Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-desktop/src/record/record_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub(crate) fn record_main(
struct AutoRotate {
pub rate: NotNan<f64>,
}
impl behavior::Behavior<character::Character> for AutoRotate {
impl behavior::Behavior<Character> for AutoRotate {
fn step(
&self,
context: &behavior::BehaviorContext<'_, Character>,
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-desktop/src/terminal/ray_image.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt;

use all_is_cubes::camera::{self, ImagePixel, Viewport};
use all_is_cubes::camera::{ImagePixel, Viewport};
use all_is_cubes::euclid::Vector2D;
use all_is_cubes::math::VectorOps;
use all_is_cubes::raytracer::RaytraceInfo;
Expand Down Expand Up @@ -33,7 +33,7 @@ impl fmt::Debug for TextRayImage {
}

impl TextRayImage {
pub fn patch_size(&self) -> Vector2D<u8, camera::ImagePixel> {
pub fn patch_size(&self) -> Vector2D<u8, ImagePixel> {
self.options.characters.rays_per_character()
}

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 @@ -81,7 +81,7 @@ struct TerminalState {
widths: HashMap<String, u16>,
}
enum MaybeTui {
Tui(tui::Terminal<CrosstermBackend<io::Stdout>>),
Tui(Terminal<CrosstermBackend<io::Stdout>>),
NoTui(CrosstermBackend<io::Stdout>),
}

Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-gpu/src/common/reloadable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use all_is_cubes::listen::{ListenableCell, ListenableSource};
pub(crate) struct Reloadable(Arc<ReloadableInner>);

pub(crate) struct ReloadableInner {
resource: Mutex<resource::Resource<str>>,
resource: Mutex<Resource<str>>,
cell: ListenableCell<Arc<str>>,
}

Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-gpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-mesh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
3 changes: 2 additions & 1 deletion all-is-cubes-port/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down Expand Up @@ -121,7 +122,7 @@ pub async fn export_to_path(
format: ExportFormat,
source: ExportSet,
destination: PathBuf,
) -> Result<(), crate::ExportError> {
) -> Result<(), ExportError> {
match format {
ExportFormat::AicJson => {
let mut writer = io::BufWriter::new(fs::File::create(destination)?);
Expand Down
6 changes: 3 additions & 3 deletions all-is-cubes-port/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) async fn export_dot_vox(
p: YieldProgress,
source: ExportSet,
mut destination: impl std::io::Write,
) -> Result<(), crate::ExportError> {
) -> Result<(), ExportError> {
let data: dot_vox::DotVoxData = export_to_dot_vox_data(p, source).await?;
data.write_vox(&mut destination)?;
Ok(())
Expand Down Expand Up @@ -91,9 +91,9 @@ pub(crate) async fn dot_vox_data_to_universe(
///
pub(crate) async fn export_to_dot_vox_data(
p: YieldProgress,
source: crate::ExportSet,
source: ExportSet,
) -> Result<dot_vox::DotVoxData, ExportError> {
let crate::ExportSet {
let ExportSet {
contents:
PartialUniverse {
blocks: block_defs,
Expand Down
10 changes: 3 additions & 7 deletions all-is-cubes-port/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use pretty_assertions::assert_eq;
use serde_json::json;

use all_is_cubes::block::{self, AIR};
use all_is_cubes::block::AIR;
use all_is_cubes::util::{assert_send_sync, yield_progress_for_testing};

use crate::file::NonDiskFile;
Expand Down Expand Up @@ -41,12 +41,8 @@ async fn import_unknown_format() {
#[test]
fn member_export_path() {
let mut universe = Universe::new();
let foo = universe
.insert("foo".into(), BlockDef::new(block::AIR))
.unwrap();
let _bar = universe
.insert("bar".into(), BlockDef::new(block::AIR))
.unwrap();
let foo = universe.insert("foo".into(), BlockDef::new(AIR)).unwrap();
let _bar = universe.insert("bar".into(), BlockDef::new(AIR)).unwrap();

assert_eq!(
ExportSet::all_of_universe(&universe)
Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-server/src/bin/aic-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
5 changes: 2 additions & 3 deletions all-is-cubes-ui/src/apps/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use all_is_cubes::fluff::Fluff;
use all_is_cubes::inv::ToolError;
use all_is_cubes::listen::{
self, Listen as _, ListenableCell, ListenableCellWithLocal, ListenableSource, Listener,
Notifier,
};
use all_is_cubes::space::{self, Space};
use all_is_cubes::time::{self, Duration};
Expand Down Expand Up @@ -58,7 +57,7 @@ pub struct Session<I> {
/// Outputs [`Fluff`] from the game character's viewpoint and also the session UI.
//---
// TODO: should include spatial information and source information
fluff_notifier: Arc<Notifier<Fluff>>,
fluff_notifier: Arc<listen::Notifier<Fluff>>,

paused: ListenableCell<bool>,

Expand Down Expand Up @@ -596,7 +595,7 @@ impl<I: time::Instant> SessionBuilder<I> {
game_universe,
space_watch_state,
game_universe_in_progress: None,
fluff_notifier: Arc::new(Notifier::new()),
fluff_notifier: Arc::new(listen::Notifier::new()),
paused,
control_channel: control_recv,
control_channel_sender: control_send,
Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-ui/src/vui/widget_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub enum InstallVuiError {
},
}

impl std::error::Error for InstallVuiError {
impl Error for InstallVuiError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
InstallVuiError::WidgetInitialization { error, .. } => Some(error),
Expand Down
1 change: 1 addition & 0 deletions all-is-cubes-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_qualifications)]
// Lenience for tests.
#![cfg_attr(test,
allow(clippy::float_cmp), // deterministic tests
Expand Down
Loading

0 comments on commit 4f5c129

Please sign in to comment.