From e02a4d41693d8d06dbe9cf9ca9e1c75816f6832e Mon Sep 17 00:00:00 2001 From: Brett Mayson Date: Wed, 27 Sep 2023 18:38:46 +0000 Subject: [PATCH] beta clippy --- Cargo.lock | 7 +++++++ bin/Cargo.toml | 1 + bin/src/modules/hook/libraries/hemtt.rs | 7 +++++++ bin/src/modules/hook/libraries/project.rs | 3 +++ bin/src/modules/hook/libraries/rfs/file.rs | 2 ++ bin/src/modules/hook/libraries/rfs/path.rs | 5 +++++ bin/src/modules/hook/libraries/version.rs | 6 ++++++ bin/src/modules/hook/libraries/vfs/file.rs | 5 +++++ bin/src/modules/hook/libraries/vfs/path.rs | 7 +++++++ 9 files changed, 43 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 6619ecbd..12e4e98b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -831,6 +831,7 @@ dependencies = [ "reqwest", "rhai", "rust-embed", + "rustversion", "semver", "serde", "serde_json", @@ -1858,6 +1859,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.15" diff --git a/bin/Cargo.toml b/bin/Cargo.toml index bce9b873..8dabc3d0 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -36,6 +36,7 @@ rayon = "1.8.0" reqwest = { version = "0.11.20", features = ["blocking", "json"] } rhai = "1.16.2" rust-embed = "8.0.0" +rustversion = "1.0.14" semver = "1.0.19" serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } diff --git a/bin/src/modules/hook/libraries/hemtt.rs b/bin/src/modules/hook/libraries/hemtt.rs index b7c3c28a..a02dd71b 100644 --- a/bin/src/modules/hook/libraries/hemtt.rs +++ b/bin/src/modules/hook/libraries/hemtt.rs @@ -28,36 +28,43 @@ impl RhaiHemtt { #[export_module] pub mod project_functions { + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn version(hemtt: &mut RhaiHemtt) -> Version { hemtt.version.clone() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn project(hemtt: &mut RhaiHemtt) -> RhaiProject { hemtt.project.clone() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn mode(hemtt: &mut RhaiHemtt) -> String { hemtt.folder.clone() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn is_dev(hemtt: &mut RhaiHemtt) -> bool { hemtt.folder == "dev" } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn is_launch(hemtt: &mut RhaiHemtt) -> bool { hemtt.folder == "launch" } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn is_build(hemtt: &mut RhaiHemtt) -> bool { hemtt.folder == "build" } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn is_release(hemtt: &mut RhaiHemtt) -> bool { hemtt.folder == "release" diff --git a/bin/src/modules/hook/libraries/project.rs b/bin/src/modules/hook/libraries/project.rs index d1841cad..3874ec97 100644 --- a/bin/src/modules/hook/libraries/project.rs +++ b/bin/src/modules/hook/libraries/project.rs @@ -30,16 +30,19 @@ impl RhaiProject { pub mod project_functions { use crate::modules::hook::libraries::project::RhaiProject; + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn name(project: &mut RhaiProject) -> String { project.name.clone() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn prefix(project: &mut RhaiProject) -> String { project.prefix.clone() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn version(project: &mut RhaiProject) -> Version { project.version.clone() diff --git a/bin/src/modules/hook/libraries/rfs/file.rs b/bin/src/modules/hook/libraries/rfs/file.rs index 4574c470..71720bd4 100644 --- a/bin/src/modules/hook/libraries/rfs/file.rs +++ b/bin/src/modules/hook/libraries/rfs/file.rs @@ -36,6 +36,7 @@ pub mod file_functions { std::fs::remove_file(path).map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn read(file: &mut ReadFile) -> Result> { let mut buf = String::new(); @@ -46,6 +47,7 @@ pub mod file_functions { .map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn write(file: &mut WriteFile, data: &str) -> Result<(), Box> { file.0 diff --git a/bin/src/modules/hook/libraries/rfs/path.rs b/bin/src/modules/hook/libraries/rfs/path.rs index 704cc912..39aac938 100644 --- a/bin/src/modules/hook/libraries/rfs/path.rs +++ b/bin/src/modules/hook/libraries/rfs/path.rs @@ -8,26 +8,31 @@ use rhai::plugin::{ pub mod path_functions { use std::path::PathBuf; + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn join(path: &mut PathBuf, other: &str) -> PathBuf { path.join(other) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn exists(path: &mut PathBuf) -> bool { path.exists() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn is_dir(path: &mut PathBuf) -> bool { path.is_dir() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn is_file(path: &mut PathBuf) -> bool { path.is_file() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, name = "to_string", name = "to_debug", pure)] pub fn to_string(path: &mut PathBuf) -> String { path.display().to_string() diff --git a/bin/src/modules/hook/libraries/version.rs b/bin/src/modules/hook/libraries/version.rs index a37bc770..9e6f7be9 100644 --- a/bin/src/modules/hook/libraries/version.rs +++ b/bin/src/modules/hook/libraries/version.rs @@ -7,11 +7,13 @@ use rhai::plugin::{ pub mod version_functions { use hemtt_common::version::Version; + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn to_string(version: &mut Version) -> String { version.to_string() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn to_string_short(version: &mut Version) -> String { format!( @@ -22,21 +24,25 @@ pub mod version_functions { ) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn major(version: &mut Version) -> i64 { i64::from(version.major()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn minor(version: &mut Version) -> i64 { i64::from(version.minor()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn patch(version: &mut Version) -> i64 { i64::from(version.patch()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure)] pub fn build(version: &mut Version) -> i64 { version.build().map(i64::from).unwrap_or_default() diff --git a/bin/src/modules/hook/libraries/vfs/file.rs b/bin/src/modules/hook/libraries/vfs/file.rs index 8119780b..d55674de 100644 --- a/bin/src/modules/hook/libraries/vfs/file.rs +++ b/bin/src/modules/hook/libraries/vfs/file.rs @@ -19,6 +19,7 @@ pub mod file_functions { use rhai::EvalAltResult; use vfs::VfsPath; + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn open_file(path: &mut VfsPath) -> Result> { path.open_file() @@ -26,6 +27,7 @@ pub mod file_functions { .map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn create_file(path: &mut VfsPath) -> Result> { path.create_file() @@ -33,11 +35,13 @@ pub mod file_functions { .map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn remove_file(path: &mut VfsPath) -> Result<(), Box> { path.remove_file().map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn read(file: &mut ReadFile) -> Result> { let mut buf = String::new(); @@ -48,6 +52,7 @@ pub mod file_functions { .map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn write(file: &mut WriteFile, data: &str) -> Result<(), Box> { file.0 diff --git a/bin/src/modules/hook/libraries/vfs/path.rs b/bin/src/modules/hook/libraries/vfs/path.rs index 660fa9f2..bd9676d1 100644 --- a/bin/src/modules/hook/libraries/vfs/path.rs +++ b/bin/src/modules/hook/libraries/vfs/path.rs @@ -8,31 +8,37 @@ pub mod path_functions { use rhai::EvalAltResult; use vfs::VfsPath; + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure, return_raw)] pub fn join(path: &mut VfsPath, other: &str) -> Result> { path.join(other).map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure, return_raw)] pub fn exists(path: &mut VfsPath) -> Result> { path.exists().map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure, return_raw)] pub fn is_dir(path: &mut VfsPath) -> Result> { path.is_dir().map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, pure, return_raw)] pub fn is_file(path: &mut VfsPath) -> Result> { path.is_file().map_err(|e| e.to_string().into()) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, name = "to_string", name = "to_debug", pure)] pub fn to_string(path: &mut VfsPath) -> String { path.as_str().to_string() } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, return_raw)] pub fn copy(path: &mut VfsPath, other: VfsPath) -> Result> { let res = if path.is_dir().map_err(|e| e.to_string())? { @@ -47,6 +53,7 @@ pub mod path_functions { res.map_or_else(|| Ok(true), Err) } + #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] #[rhai_fn(global, name = "move", return_raw)] pub fn _move(path: &mut VfsPath, other: VfsPath) -> Result> { let res = if path.is_dir().map_err(|e| e.to_string())? {