Skip to content

Commit

Permalink
beta clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Sep 27, 2023
1 parent d3be0ba commit e02a4d4
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
7 changes: 7 additions & 0 deletions bin/src/modules/hook/libraries/hemtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions bin/src/modules/hook/libraries/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions bin/src/modules/hook/libraries/rfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Box<EvalAltResult>> {
let mut buf = String::new();
Expand All @@ -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<EvalAltResult>> {
file.0
Expand Down
5 changes: 5 additions & 0 deletions bin/src/modules/hook/libraries/rfs/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions bin/src/modules/hook/libraries/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions bin/src/modules/hook/libraries/vfs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@ 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<ReadFile, Box<EvalAltResult>> {
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)]
pub fn create_file(path: &mut VfsPath) -> Result<WriteFile, Box<EvalAltResult>> {
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)]
pub fn remove_file(path: &mut VfsPath) -> Result<(), Box<EvalAltResult>> {
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<String, Box<EvalAltResult>> {
let mut buf = String::new();
Expand All @@ -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<EvalAltResult>> {
file.0
Expand Down
7 changes: 7 additions & 0 deletions bin/src/modules/hook/libraries/vfs/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<VfsPath, Box<EvalAltResult>> {
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<bool, Box<EvalAltResult>> {
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<bool, Box<EvalAltResult>> {
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<bool, Box<EvalAltResult>> {
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<bool, Box<EvalAltResult>> {
let res = if path.is_dir().map_err(|e| e.to_string())? {
Expand All @@ -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<bool, Box<EvalAltResult>> {
let res = if path.is_dir().map_err(|e| e.to_string())? {
Expand Down

0 comments on commit e02a4d4

Please sign in to comment.