Skip to content

Commit

Permalink
chore: 🚨 fix wasily fixable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Nov 29, 2023
1 parent fcbac2a commit 95c958d
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 49 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ rust_2018_idioms = "warn"
unsafe_code = "warn"
# clearly denote where you are using unsafe code in unsafe fns. in a future rust edition this will become a hard error.
unsafe_op_in_unsafe_fn = "forbid"
# will become a hard error in a future rust edition
elided_lifetimes_in_paths = "forbid"

[workspace.lints.clippy]
all = "warn"
Expand Down
20 changes: 9 additions & 11 deletions crates/components/src/command_view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,31 @@ mod ui;
use std::collections::HashMap;

pub struct CommandView {
selected_index: usize,
window_state: WindowState,
id: egui::Id,
modals: HashMap<u64, bool>, // todo find a better way to handle modals
_selected_index: usize,
_window_state: WindowState,
_id: egui::Id,
_modals: HashMap<u64, bool>, // todo find a better way to handle modals
}

enum WindowState {
Insert { index: usize, tab: usize },
Edit { index: usize },
None,
}

impl Default for CommandView {
fn default() -> Self {
Self {
selected_index: 0,
window_state: WindowState::None,
id: egui::Id::new("command_view"),
modals: HashMap::new(),
_selected_index: 0,
_window_state: WindowState::None,
_id: egui::Id::new("command_view"),
_modals: HashMap::new(),
}
}
}

impl CommandView {
pub fn new(id: impl std::hash::Hash) -> Self {
Self {
id: egui::Id::new(id),
_id: egui::Id::new(id),
..Default::default()
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/components/src/map_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ impl MapView {
})
}

// FIXME
// FIXME lots of arguments
#[allow(clippy::too_many_arguments)]
pub fn ui(
&mut self,
ui: &mut egui::Ui,
Expand Down
9 changes: 5 additions & 4 deletions crates/components/src/tilepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// along with Luminol. If not, see <http://www.gnu.org/licenses/>.

use itertools::Itertools;
use slab::Slab;
use std::sync::Arc;
use std::time::Duration;

Expand Down Expand Up @@ -47,8 +46,12 @@ struct Callback {
coll_enabled: bool,
}

// FIXME
//? SAFETY:
//? wgpu resources are not Send + Sync on wasm, but egui_wgpu::CallbackTrait requires Send + Sync (because egui::Context is Send + Sync)
//? as long as this callback does not leave the thread it was created on on wasm (which it shouldn't be) these are ok.
#[allow(unsafe_code)]
unsafe impl Send for Callback {}
#[allow(unsafe_code)]
unsafe impl Sync for Callback {}

impl egui_wgpu::CallbackTrait for Callback {
Expand Down Expand Up @@ -107,8 +110,6 @@ impl Default for SelectedTile {
}
}

type ResourcesSlab = Slab<Arc<Resources>>;

impl Tilepicker {
pub fn new(
update_state: &luminol_core::UpdateState<'_>,
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ macro_rules! nested_ref_getter {
($($typ:ty, $name:ident),* $(,)?) => {
$(
#[allow(unsafe_code, dead_code)]
pub fn $name(&self) -> RefMut<$typ> {
pub fn $name(&self) -> RefMut<'_, $typ> {
match self {
Self::Unloaded => panic!("data cache unloaded"),
Self::Loaded { $name, ..} => $name.borrow_mut(),
Expand Down Expand Up @@ -389,7 +389,7 @@ impl Data {
&self,
id: usize,
filesystem: &impl luminol_filesystem::FileSystem,
) -> RefMut<rpg::Map> {
) -> RefMut<'_, rpg::Map> {
let maps_ref = match self {
Self::Loaded { maps, .. } => maps.borrow_mut(),
Self::Unloaded => panic!("project not loaded"),
Expand All @@ -402,7 +402,7 @@ impl Data {
})
}

pub fn get_map(&self, id: usize) -> RefMut<rpg::Map> {
pub fn get_map(&self, id: usize) -> RefMut<'_, rpg::Map> {
let maps_ref = match self {
Self::Loaded { maps, .. } => maps.borrow_mut(),
Self::Unloaded => panic!("project not loaded"),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Tabs {
}

/// Display all tabs.
pub fn ui(&mut self, ui: &mut egui::Ui, update_state: &mut crate::UpdateState) {
pub fn ui(&mut self, ui: &mut egui::Ui, update_state: &mut crate::UpdateState<'_>) {
let mut edit_tabs = EditTabs::default();
let mut update_state = update_state.reborrow_with_edit_tabs(&mut edit_tabs);
self.ui_without_edit(ui, &mut update_state);
Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/helpers/id_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ where
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = Vec<usize>;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("a vec of nonzero usizes")
}

Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/helpers/optional_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
impl serde::de::Visitor<'_> for Visitor {
type Value = Option<Utf8PathBuf>;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("a string")
}

Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/option_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ where
{
type Value = OptionVec<T>;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("a key-value mapping")
}

Expand Down
2 changes: 0 additions & 2 deletions crates/filesystem/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use crate::FileSystem as _;
use crate::{archiver, host, list, path_cache};
use crate::{DirEntry, Error, Metadata, OpenFlags, Result};

use itertools::Itertools;

#[derive(Default)]
pub enum FileSystem {
#[default]
Expand Down
6 changes: 5 additions & 1 deletion crates/graphics/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ struct Callback {
graphics_state: Arc<crate::GraphicsState>,
}

// FIXME
//? SAFETY:
//? wgpu resources are not Send + Sync on wasm, but egui_wgpu::CallbackTrait requires Send + Sync (because egui::Context is Send + Sync)
//? as long as this callback does not leave the thread it was created on on wasm (which it shouldn't be) these are ok.
#[allow(unsafe_code)]
unsafe impl Send for Callback {}
#[allow(unsafe_code)]
unsafe impl Sync for Callback {}

impl egui_wgpu::CallbackTrait for Callback {
Expand Down
8 changes: 7 additions & 1 deletion crates/graphics/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ struct OverlayCallback {
coll_enabled: bool,
}

// FIXME
//? SAFETY:
//? wgpu resources are not Send + Sync on wasm, but egui_wgpu::CallbackTrait requires Send + Sync (because egui::Context is Send + Sync)
//? as long as this callback does not leave the thread it was created on on wasm (which it shouldn't be) these are ok.
#[allow(unsafe_code)]
unsafe impl Send for Callback {}
#[allow(unsafe_code)]
unsafe impl Sync for Callback {}
#[allow(unsafe_code)]
unsafe impl Send for OverlayCallback {}
#[allow(unsafe_code)]
unsafe impl Sync for OverlayCallback {}

impl egui_wgpu::CallbackTrait for Callback {
Expand Down
3 changes: 2 additions & 1 deletion crates/graphics/src/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub struct Plane {
}

impl Plane {
// FIXME: holy SHIT
// FIXME lots of arguments
#[allow(clippy::too_many_arguments)]
pub fn new(
graphics_state: &crate::GraphicsState,
texture: std::sync::Arc<crate::image_cache::WgpuTexture>,
Expand Down
2 changes: 1 addition & 1 deletion crates/modals/src/sound_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Program grant you additional permission to convey the resulting work.

pub struct Modal {
tab: luminol_components::SoundTab,
_tab: luminol_components::SoundTab,
}

impl luminol_core::Modal for Modal {
Expand Down
22 changes: 10 additions & 12 deletions crates/ui/src/windows/event_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.



/// The event editor window.
pub struct Window {
id: usize,
map_id: usize,
selected_page: usize,
_selected_page: usize,
name: String,
viewed_tab: u8,
_viewed_tab: u8,

switch_modal_1: Option<luminol_modals::switch::Modal>,
switch_modal_2: Option<luminol_modals::switch::Modal>,
variable_modal: Option<luminol_modals::variable::Modal>,
_switch_modal_1: Option<luminol_modals::switch::Modal>,
_switch_modal_2: Option<luminol_modals::switch::Modal>,
_variable_modal: Option<luminol_modals::variable::Modal>,
}

impl Window {
Expand All @@ -43,13 +41,13 @@ impl Window {
Self {
id,
map_id,
selected_page: 0,
_selected_page: 0,
name: String::from("(unknown)"),
viewed_tab: 2,
_viewed_tab: 2,

switch_modal_1: None,
switch_modal_2: None,
variable_modal: None,
_switch_modal_1: None,
_switch_modal_2: None,
_variable_modal: None,
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions crates/ui/src/windows/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.

use luminol_core::Modal;

/// Database - Items management window.
pub struct Window {
// ? Items ?
items: luminol_data::rpg::Items,
selected_item: usize,

// ? Icon Graphic Picker ?
icon_picker: Option<luminol_modals::graphic_picker::Modal>,
_icon_picker: Option<luminol_modals::graphic_picker::Modal>,

// ? Menu Sound Effect Picker ?
menu_se_picker: Option<luminol_modals::sound_picker::Modal>,
_menu_se_picker: Option<luminol_modals::sound_picker::Modal>,
}

impl Window {
Expand All @@ -45,9 +43,9 @@ impl Window {
items,
selected_item: 0,

icon_picker: None,
_icon_picker: None,

menu_se_picker: None,
_menu_se_picker: None,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct App {
toolbar: luminol_core::ToolbarState,

#[cfg(not(target_arch = "wasm32"))]
runtime: tokio::runtime::Runtime,
_runtime: tokio::runtime::Runtime,

#[cfg(feature = "steamworks")]
steamworks: Steamworks,
Expand Down Expand Up @@ -181,7 +181,7 @@ impl App {
toolbar: luminol_core::ToolbarState::default(),

#[cfg(not(target_arch = "wasm32"))]
runtime,
_runtime: runtime,

#[cfg(feature = "steamworks")]
steamworks,
Expand Down

0 comments on commit 95c958d

Please sign in to comment.