From de0891b1da994b92b6f8ef59e72ad4888469c59c Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 11:52:41 -0700 Subject: [PATCH 1/7] Update to Rust 1.62.0 --- .github/workflows/build.yaml | 8 ++++---- Cargo.toml | 2 +- README.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 45b83e0..15893cf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,7 +11,7 @@ jobs: uses: actions-rs/toolchain@v1 with: # TODO: refactor toolchain version - toolchain: 1.59.0 + toolchain: 1.62.0 components: clippy, rustfmt default: true - name: Install dependencies @@ -60,7 +60,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.59.0 + toolchain: 1.62.0 components: clippy, rustfmt default: true - name: Build binary @@ -105,7 +105,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.59.0 + toolchain: 1.62.0 components: clippy, rustfmt default: true - name: Build binary @@ -161,7 +161,7 @@ jobs: uses: actions-rs/toolchain@v1 with: # TODO: refactor toolchain version - toolchain: 1.59.0 + toolchain: 1.62.0 components: clippy, rustfmt default: true - name: Install wasm-pack diff --git a/Cargo.toml b/Cargo.toml index 25dd452..94cc26f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "stevenarella" version = "0.0.1" authors = [ "Thinkofdeath ", "iceiix " ] edition = "2021" -rust-version = "1.59.0" +rust-version = "1.62.0" resolver = "2" description = "Multi-protocol multi-platform Minecraft-compatible client" repository = "https://github.com/iceiix/stevenarella" diff --git a/README.md b/README.md index b1b9c33..5abcf98 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ from [GitHub Actions](https://actions-badge.atrox.dev/iceiix/stevenarella/goto?r ## Dependencies -Requires Rust stable version 1.59.0 or newer. +Requires Rust stable version 1.62.0 or newer. **Debian/Ubuntu** From 4c45ada7ef7f48f9e0e9661165c8be7e1b885007 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:18:46 -0700 Subject: [PATCH 2/7] Fix clippy::drop_non_drop on MaybeUninit in ecs std::mem::drop was called on a value which does not implement `Drop`, specifically std::mem::MaybeUninit. According to the Clippy warning, this only extends its contained lifetime. Change to assume_init_drop(). --- src/ecs/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ecs/mod.rs b/src/ecs/mod.rs index 82b44bb..80d394d 100644 --- a/src/ecs/mod.rs +++ b/src/ecs/mod.rs @@ -603,7 +603,7 @@ impl ComponentMem { drop_func: Box::new(|data| unsafe { let mut val = mem::MaybeUninit::::uninit(); ptr::copy(data as *mut T, val.as_mut_ptr(), 1); - mem::drop(val); + val.assume_init_drop(); }), } } From 46535904bc0662992470d8d1f270dfb24bbf97e3 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:22:31 -0700 Subject: [PATCH 3/7] Update to Rust 1.63.0 --- .github/workflows/build.yaml | 8 ++++---- Cargo.toml | 2 +- README.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 15893cf..3669046 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,7 +11,7 @@ jobs: uses: actions-rs/toolchain@v1 with: # TODO: refactor toolchain version - toolchain: 1.62.0 + toolchain: 1.63.0 components: clippy, rustfmt default: true - name: Install dependencies @@ -60,7 +60,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.62.0 + toolchain: 1.63.0 components: clippy, rustfmt default: true - name: Build binary @@ -105,7 +105,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.62.0 + toolchain: 1.63.0 components: clippy, rustfmt default: true - name: Build binary @@ -161,7 +161,7 @@ jobs: uses: actions-rs/toolchain@v1 with: # TODO: refactor toolchain version - toolchain: 1.62.0 + toolchain: 1.63.0 components: clippy, rustfmt default: true - name: Install wasm-pack diff --git a/Cargo.toml b/Cargo.toml index 94cc26f..dda8736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "stevenarella" version = "0.0.1" authors = [ "Thinkofdeath ", "iceiix " ] edition = "2021" -rust-version = "1.62.0" +rust-version = "1.63.0" resolver = "2" description = "Multi-protocol multi-platform Minecraft-compatible client" repository = "https://github.com/iceiix/stevenarella" diff --git a/README.md b/README.md index 5abcf98..734f4c7 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ from [GitHub Actions](https://actions-badge.atrox.dev/iceiix/stevenarella/goto?r ## Dependencies -Requires Rust stable version 1.62.0 or newer. +Requires Rust stable version 1.63.0 or newer. **Debian/Ubuntu** From e8558b427a02819ece68796b296aac856a993cba Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:27:28 -0700 Subject: [PATCH 4/7] Fix clippy::type_complexity, refactor type alias Use a type alias to refactor the submit_funcs type definition, as a vector of boxed SubmitFuncs. Note this type alias isn't used in the parameterized add_submit_func() function because it accepts a trait, not a type - no `dyn` keyword in this context, but it is needed in the type definition. --- src/ui/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 15b4b09..43e1b4e 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1494,6 +1494,8 @@ impl Button { } } +type SubmitFunc = dyn Fn(&mut TextBox, &mut crate::Game); + element! { ref TextBoxRef pub struct TextBox { @@ -1505,7 +1507,7 @@ element! { priv text: Option, priv was_focused: bool, priv cursor_tick: f64, - priv submit_funcs: Vec>, + priv submit_funcs: Vec>, } builder TextBoxBuilder { hardcode button = None, From ab5f87effdac476c3dbfe8cb6a6d48dc05fb11f7 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:31:24 -0700 Subject: [PATCH 5/7] Update to Rust 1.64.0 --- .github/workflows/build.yaml | 8 ++++---- Cargo.toml | 2 +- README.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3669046..6b713d3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,7 +11,7 @@ jobs: uses: actions-rs/toolchain@v1 with: # TODO: refactor toolchain version - toolchain: 1.63.0 + toolchain: 1.64.0 components: clippy, rustfmt default: true - name: Install dependencies @@ -60,7 +60,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.63.0 + toolchain: 1.64.0 components: clippy, rustfmt default: true - name: Build binary @@ -105,7 +105,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.63.0 + toolchain: 1.64.0 components: clippy, rustfmt default: true - name: Build binary @@ -161,7 +161,7 @@ jobs: uses: actions-rs/toolchain@v1 with: # TODO: refactor toolchain version - toolchain: 1.63.0 + toolchain: 1.64.0 components: clippy, rustfmt default: true - name: Install wasm-pack diff --git a/Cargo.toml b/Cargo.toml index dda8736..359268a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "stevenarella" version = "0.0.1" authors = [ "Thinkofdeath ", "iceiix " ] edition = "2021" -rust-version = "1.63.0" +rust-version = "1.64.0" resolver = "2" description = "Multi-protocol multi-platform Minecraft-compatible client" repository = "https://github.com/iceiix/stevenarella" diff --git a/README.md b/README.md index 734f4c7..9fdfd37 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ from [GitHub Actions](https://actions-badge.atrox.dev/iceiix/stevenarella/goto?r ## Dependencies -Requires Rust stable version 1.63.0 or newer. +Requires Rust stable version 1.64.0 or newer. **Debian/Ubuntu** From 6394b60a3906dfc26909f360ede3e0594a3051c5 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:32:31 -0700 Subject: [PATCH 6/7] Fix clippy::needless_borrow in console Clippy says the compiler automatically borrows this --- src/console/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console/mod.rs b/src/console/mod.rs index 28b0689..72acfaa 100644 --- a/src/console/mod.rs +++ b/src/console/mod.rs @@ -135,7 +135,7 @@ impl Var for CVar { } fn deserialize(&self, input: &str) -> Box { - Box::new((&input[1..input.len() - 1]).to_owned()) + Box::new(input[1..input.len() - 1].to_owned()) } fn description(&self) -> &'static str { From e4c5e61857ff712b95c4f6cb31bcdadbb8b3c498 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Oct 2022 15:36:50 -0700 Subject: [PATCH 7/7] Fix clippy::manual_find, replace with an iterator This manual implementation of Iterator::find can be replaced with `find`, which has the same performance, but Clippy considers easier to read than the original implementation. --- src/settings.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/settings.rs b/src/settings.rs index 72b20f7..3fc31c6 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -115,12 +115,9 @@ impl Stevenkey { } pub fn get_by_keycode(keycode: VirtualKeyCode, vars: &console::Vars) -> Option { - for steven_key in Stevenkey::values() { - if keycode as i64 == *vars.get(steven_key.get_cvar()) { - return Some(steven_key); - } - } - None + Stevenkey::values() + .into_iter() + .find(|steven_key| keycode as i64 == *vars.get(steven_key.get_cvar())) } pub fn get_cvar(&self) -> console::CVar {