From 6a6111e435d97393b290bdd68137dcf057247f82 Mon Sep 17 00:00:00 2001 From: BrettMayson Date: Fri, 13 Oct 2023 11:20:37 -0600 Subject: [PATCH] 1.73 cleanup --- bin/src/modules/asc.rs | 3 ++- bin/src/modules/hook/libraries/hemtt.rs | 8 +------- bin/src/modules/hook/libraries/project.rs | 4 +--- bin/src/modules/hook/libraries/rfs/file.rs | 4 ++-- bin/src/modules/hook/libraries/rfs/path.rs | 6 +----- bin/src/modules/hook/libraries/version.rs | 7 +------ bin/src/modules/hook/libraries/vfs/file.rs | 12 ++++-------- bin/src/modules/hook/libraries/vfs/path.rs | 8 +------- bin/src/modules/mod.rs | 2 +- bin/src/modules/rapifier.rs | 2 +- libs/preprocessor/src/processor/directives.rs | 6 +----- 11 files changed, 16 insertions(+), 46 deletions(-) diff --git a/bin/src/modules/asc.rs b/bin/src/modules/asc.rs index 536859a1..840c83d8 100644 --- a/bin/src/modules/asc.rs +++ b/bin/src/modules/asc.rs @@ -211,7 +211,7 @@ impl Module for ArmaScriptCompiler { } #[derive(Default, Serialize)] -struct ASCConfig { +pub struct ASCConfig { #[serde(rename = "inputDirs")] input_dirs: Vec, #[serde(rename = "outputDir")] @@ -225,6 +225,7 @@ struct ASCConfig { } impl ASCConfig { + #[must_use] pub const fn new() -> Self { Self { input_dirs: vec![], diff --git a/bin/src/modules/hook/libraries/hemtt.rs b/bin/src/modules/hook/libraries/hemtt.rs index a02dd71b..612e3fe4 100644 --- a/bin/src/modules/hook/libraries/hemtt.rs +++ b/bin/src/modules/hook/libraries/hemtt.rs @@ -26,45 +26,39 @@ impl RhaiHemtt { } } +#[allow(clippy::needless_pass_by_ref_mut)] #[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 3874ec97..2de1faab 100644 --- a/bin/src/modules/hook/libraries/project.rs +++ b/bin/src/modules/hook/libraries/project.rs @@ -26,23 +26,21 @@ impl RhaiProject { } } +#[allow(clippy::needless_pass_by_ref_mut)] #[export_module] 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 71720bd4..257c01b9 100644 --- a/bin/src/modules/hook/libraries/rfs/file.rs +++ b/bin/src/modules/hook/libraries/rfs/file.rs @@ -36,7 +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))] + #[allow(clippy::needless_pass_by_ref_mut)] #[rhai_fn(global, return_raw)] pub fn read(file: &mut ReadFile) -> Result> { let mut buf = String::new(); @@ -47,7 +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))] + #[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 39aac938..8c190c67 100644 --- a/bin/src/modules/hook/libraries/rfs/path.rs +++ b/bin/src/modules/hook/libraries/rfs/path.rs @@ -3,36 +3,32 @@ use rhai::plugin::{ PluginFunction, RhaiResult, TypeId, }; +#[allow(clippy::needless_pass_by_ref_mut)] #[allow(clippy::ptr_arg)] #[export_module] 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 9e6f7be9..266347ca 100644 --- a/bin/src/modules/hook/libraries/version.rs +++ b/bin/src/modules/hook/libraries/version.rs @@ -3,17 +3,16 @@ use rhai::plugin::{ RhaiResult, TypeId, }; +#[allow(clippy::needless_pass_by_ref_mut)] #[export_module] 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!( @@ -24,25 +23,21 @@ 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 d55674de..2df4846b 100644 --- a/bin/src/modules/hook/libraries/vfs/file.rs +++ b/bin/src/modules/hook/libraries/vfs/file.rs @@ -12,6 +12,7 @@ pub struct ReadFile(Rc>>); #[derive(Clone)] pub struct WriteFile(Rc>>); +#[allow(clippy::needless_pass_by_ref_mut)] #[export_module] pub mod file_functions { use std::{cell::RefCell, rc::Rc}; @@ -19,29 +20,25 @@ 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)] + #[rhai_fn(global, pure, return_raw)] pub fn open_file(path: &mut VfsPath) -> Result> { path.open_file() .map(|f| ReadFile(Rc::new(RefCell::new(f)))) .map_err(|e| e.to_string().into()) } - #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] - #[rhai_fn(global, return_raw)] + #[rhai_fn(global, pure, return_raw)] pub fn create_file(path: &mut VfsPath) -> Result> { path.create_file() .map(|f| WriteFile(Rc::new(RefCell::new(f)))) .map_err(|e| e.to_string().into()) } - #[rustversion::attr(since(1.73), allow(clippy::needless_pass_by_ref_mut))] - #[rhai_fn(global, return_raw)] + #[rhai_fn(global, pure, 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(); @@ -52,7 +49,6 @@ 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 bd9676d1..e57550c1 100644 --- a/bin/src/modules/hook/libraries/vfs/path.rs +++ b/bin/src/modules/hook/libraries/vfs/path.rs @@ -3,42 +3,37 @@ use rhai::plugin::{ PluginFunction, RhaiResult, TypeId, }; +#[allow(clippy::needless_pass_by_ref_mut)] #[export_module] 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())? { @@ -53,7 +48,6 @@ 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())? { diff --git a/bin/src/modules/mod.rs b/bin/src/modules/mod.rs index 560b2ab9..ef9b5865 100644 --- a/bin/src/modules/mod.rs +++ b/bin/src/modules/mod.rs @@ -17,7 +17,7 @@ mod rapifier; mod sign; #[cfg(not(target_os = "macos"))] -pub use asc::ArmaScriptCompiler; +pub use asc::{ASCConfig, ArmaScriptCompiler}; pub use binarize::Binarize; pub use file_patching::FilePatching; pub use files::Files; diff --git a/bin/src/modules/rapifier.rs b/bin/src/modules/rapifier.rs index 3f5168e1..c34fdb49 100644 --- a/bin/src/modules/rapifier.rs +++ b/bin/src/modules/rapifier.rs @@ -44,7 +44,7 @@ impl Module for Rapifier { } let mut messages = Vec::new(); let mut res = Ok(()); - for entry in ctx.workspace().join(&addon.folder())?.walk_dir()? { + for entry in ctx.workspace().join(addon.folder())?.walk_dir()? { if entry.metadata()?.file_type == VfsFileType::File && can_preprocess(entry.as_str()) { diff --git a/libs/preprocessor/src/processor/directives.rs b/libs/preprocessor/src/processor/directives.rs index cb5d4ff5..b054aff4 100644 --- a/libs/preprocessor/src/processor/directives.rs +++ b/libs/preprocessor/src/processor/directives.rs @@ -83,7 +83,7 @@ impl Processor { Self::expect_nothing_to_newline(stream)?; Ok(()) } - ("pragma", _) => { + ("pragma", _) | (_, false) => { // TODO: hemtt pragma self.skip_to_after_newline(stream, None); Ok(()) @@ -91,10 +91,6 @@ impl Processor { (_, true) => Err(Error::Code(Box::new(UnknownDirective { token: Box::new(command), }))), - (_, false) => { - self.skip_to_after_newline(stream, None); - Ok(()) - } } }