Fix all new clippy lints

This commit is contained in:
Filip Tibell 2025-04-23 13:19:19 +02:00
parent dd7f6d613b
commit 02fb2dc662
No known key found for this signature in database
17 changed files with 52 additions and 54 deletions

View file

@ -323,7 +323,7 @@ impl LuaUserData for CFrame {
} else if let Ok(vec) = ud.borrow::<Vector3>() { } else if let Ok(vec) = ud.borrow::<Vector3>() {
return lua.create_userdata(*this * *vec); return lua.create_userdata(*this * *vec);
} }
}; }
Err(LuaError::FromLuaConversionError { Err(LuaError::FromLuaConversionError {
from: rhs.type_name(), from: rhs.type_name(),
to: "userdata", to: "userdata",

View file

@ -4,11 +4,10 @@ use std::{
collections::{BTreeMap, VecDeque}, collections::{BTreeMap, VecDeque},
fmt, fmt,
hash::{Hash, Hasher}, hash::{Hash, Hasher},
sync::Mutex, sync::{LazyLock, Mutex},
}; };
use mlua::prelude::*; use mlua::prelude::*;
use once_cell::sync::Lazy;
use rbx_dom_weak::{ use rbx_dom_weak::{
types::{Attributes as DomAttributes, Ref as DomRef, Variant as DomValue}, types::{Attributes as DomAttributes, Ref as DomRef, Variant as DomValue},
ustr, Instance as DomInstance, InstanceBuilder as DomInstanceBuilder, Ustr, WeakDom, ustr, Instance as DomInstance, InstanceBuilder as DomInstanceBuilder, Ustr, WeakDom,
@ -31,8 +30,8 @@ pub mod registry;
const PROPERTY_NAME_ATTRIBUTES: &str = "Attributes"; const PROPERTY_NAME_ATTRIBUTES: &str = "Attributes";
const PROPERTY_NAME_TAGS: &str = "Tags"; const PROPERTY_NAME_TAGS: &str = "Tags";
static INTERNAL_DOM: Lazy<Mutex<WeakDom>> = static INTERNAL_DOM: LazyLock<Mutex<WeakDom>> =
Lazy::new(|| Mutex::new(WeakDom::new(DomInstanceBuilder::new("ROOT")))); LazyLock::new(|| Mutex::new(WeakDom::new(DomInstanceBuilder::new("ROOT"))));
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Instance { pub struct Instance {
@ -694,8 +693,7 @@ impl Instance {
predicate callback and a breadth-first search. predicate callback and a breadth-first search.
### See Also ### See Also
* [`FindFirstDescendant`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstDescendant) * [`FindFirstDescendant`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstDescendant) on the Roblox Developer Hub
on the Roblox Developer Hub
*/ */
pub fn find_descendant<F>(&self, predicate: F) -> Option<Instance> pub fn find_descendant<F>(&self, predicate: F) -> Option<Instance>
where where

View file

@ -87,7 +87,7 @@ where
} }
} }
_ => {} _ => {}
}; }
Err(LuaError::FromLuaConversionError { Err(LuaError::FromLuaConversionError {
from: rhs.type_name(), from: rhs.type_name(),
to: type_name::<D>(), to: type_name::<D>(),
@ -112,7 +112,7 @@ where
} }
} }
_ => {} _ => {}
}; }
Err(LuaError::FromLuaConversionError { Err(LuaError::FromLuaConversionError {
from: rhs.type_name(), from: rhs.type_name(),
to: type_name::<D>(), to: type_name::<D>(),
@ -137,7 +137,7 @@ where
} }
} }
_ => {} _ => {}
}; }
Err(LuaError::FromLuaConversionError { Err(LuaError::FromLuaConversionError {
from: rhs.type_name(), from: rhs.type_name(),
to: type_name::<D>(), to: type_name::<D>(),
@ -168,7 +168,7 @@ where
} }
} }
_ => {} _ => {}
}; }
Err(LuaError::FromLuaConversionError { Err(LuaError::FromLuaConversionError {
from: rhs.type_name(), from: rhs.type_name(),
to: type_name::<D>(), to: type_name::<D>(),
@ -193,7 +193,7 @@ where
} }
} }
_ => {} _ => {}
}; }
Err(LuaError::FromLuaConversionError { Err(LuaError::FromLuaConversionError {
from: rhs.type_name(), from: rhs.type_name(),
to: type_name::<D>(), to: type_name::<D>(),

View file

@ -76,7 +76,7 @@ impl FromLua<'_> for DateTimeValues {
to: "DateTimeValues", to: "DateTimeValues",
message: Some("value must be a table".to_string()), message: Some("value must be a table".to_string()),
}); });
}; }
let value = value.as_table().unwrap(); let value = value.as_table().unwrap();
let values = Self { let values = Self {

View file

@ -62,7 +62,7 @@ impl<'lua> FromLua<'lua> for ProcessSpawnOptions {
return Err(LuaError::runtime( return Err(LuaError::runtime(
"Invalid value for option 'cwd' - path does not exist", "Invalid value for option 'cwd' - path does not exist",
)); ));
}; }
this.cwd = Some(cwd); this.cwd = Some(cwd);
} }
value => { value => {

View file

@ -192,7 +192,7 @@ pub fn prompt(options: PromptOptions) -> LuaResult<PromptResult> {
let mut prompt = Confirm::with_theme(&theme); let mut prompt = Confirm::with_theme(&theme);
if let Some(b) = options.default_bool { if let Some(b) = options.default_bool {
prompt = prompt.default(b); prompt = prompt.default(b);
}; }
let result = prompt let result = prompt
.with_prompt(options.text.expect("Missing text in prompt options")) .with_prompt(options.text.expect("Missing text in prompt options"))
.interact() .interact()

View file

@ -266,7 +266,7 @@ impl RequireContext {
Ok(LuaMultiValue::from_vec(multi_vec)) Ok(LuaMultiValue::from_vec(multi_vec))
} }
}; };
}; }
let result = library.module(lua); let result = library.module(lua);

View file

@ -1,14 +1,15 @@
use std::fmt; use std::{
use std::str::FromStr; fmt,
use std::sync::Arc; str::FromStr,
sync::{Arc, LazyLock},
};
use console::style; use console::style;
use mlua::prelude::*; use mlua::prelude::*;
use once_cell::sync::Lazy;
use super::StackTrace; use super::StackTrace;
static STYLED_STACK_BEGIN: Lazy<String> = Lazy::new(|| { static STYLED_STACK_BEGIN: LazyLock<String> = LazyLock::new(|| {
format!( format!(
"{}{}{}", "{}{}{}",
style("[").dim(), style("[").dim(),
@ -17,7 +18,7 @@ static STYLED_STACK_BEGIN: Lazy<String> = Lazy::new(|| {
) )
}); });
static STYLED_STACK_END: Lazy<String> = Lazy::new(|| { static STYLED_STACK_END: LazyLock<String> = LazyLock::new(|| {
format!( format!(
"{}{}{}", "{}{}{}",
style("[").dim(), style("[").dim(),

View file

@ -1,8 +1,10 @@
use std::{collections::HashSet, sync::Arc}; use std::{
collections::HashSet,
sync::{Arc, LazyLock},
};
use console::{colors_enabled as get_colors_enabled, set_colors_enabled}; use console::{colors_enabled as get_colors_enabled, set_colors_enabled};
use mlua::prelude::*; use mlua::prelude::*;
use once_cell::sync::Lazy;
use parking_lot::ReentrantMutex; use parking_lot::ReentrantMutex;
mod basic; mod basic;
@ -18,7 +20,8 @@ pub use self::config::ValueFormatConfig;
// NOTE: Since the setting for colors being enabled is global, // NOTE: Since the setting for colors being enabled is global,
// and these functions may be called in parallel, we use this global // and these functions may be called in parallel, we use this global
// lock to make sure that we don't mess up the colors for other threads. // lock to make sure that we don't mess up the colors for other threads.
static COLORS_LOCK: Lazy<Arc<ReentrantMutex<()>>> = Lazy::new(|| Arc::new(ReentrantMutex::new(()))); static COLORS_LOCK: LazyLock<Arc<ReentrantMutex<()>>> =
LazyLock::new(|| Arc::new(ReentrantMutex::new(())));
/** /**
Formats a Lua value into a pretty string using the given config. Formats a Lua value into a pretty string using the given config.

View file

@ -1,9 +1,10 @@
use std::sync::LazyLock;
use console::Style; use console::Style;
use once_cell::sync::Lazy;
pub static COLOR_GREEN: Lazy<Style> = Lazy::new(|| Style::new().green()); pub static COLOR_GREEN: LazyLock<Style> = LazyLock::new(|| Style::new().green());
pub static COLOR_YELLOW: Lazy<Style> = Lazy::new(|| Style::new().yellow()); pub static COLOR_YELLOW: LazyLock<Style> = LazyLock::new(|| Style::new().yellow());
pub static COLOR_MAGENTA: Lazy<Style> = Lazy::new(|| Style::new().magenta()); pub static COLOR_MAGENTA: LazyLock<Style> = LazyLock::new(|| Style::new().magenta());
pub static COLOR_CYAN: Lazy<Style> = Lazy::new(|| Style::new().cyan()); pub static COLOR_CYAN: LazyLock<Style> = LazyLock::new(|| Style::new().cyan());
pub static STYLE_DIM: Lazy<Style> = Lazy::new(|| Style::new().dim()); pub static STYLE_DIM: LazyLock<Style> = LazyLock::new(|| Style::new().dim());

View file

@ -1,14 +1,13 @@
use std::{ use std::{
env::{current_dir, current_exe}, env::{current_dir, current_exe},
path::{Path, PathBuf, MAIN_SEPARATOR}, path::{Path, PathBuf, MAIN_SEPARATOR},
sync::Arc, sync::{Arc, LazyLock},
}; };
use once_cell::sync::Lazy;
use path_clean::PathClean; use path_clean::PathClean;
static CWD: Lazy<Arc<Path>> = Lazy::new(create_cwd); static CWD: LazyLock<Arc<Path>> = LazyLock::new(create_cwd);
static EXE: Lazy<Arc<Path>> = Lazy::new(create_exe); static EXE: LazyLock<Arc<Path>> = LazyLock::new(create_exe);
fn create_cwd() -> Arc<Path> { fn create_cwd() -> Arc<Path> {
let mut cwd = current_dir() let mut cwd = current_dir()

View file

@ -1,10 +1,9 @@
use std::sync::Arc; use std::sync::{Arc, LazyLock};
use mlua::prelude::*; use mlua::prelude::*;
use once_cell::sync::Lazy;
use semver::Version; use semver::Version;
static LUAU_VERSION: Lazy<Arc<String>> = Lazy::new(create_luau_version_string); static LUAU_VERSION: LazyLock<Arc<String>> = LazyLock::new(create_luau_version_string);
/** /**
Returns a Lune version string, in the format `Lune x.y.z+luau`. Returns a Lune version string, in the format `Lune x.y.z+luau`.

View file

@ -1,16 +1,15 @@
use std::{env::consts::ARCH, fmt, path::PathBuf, str::FromStr}; use std::{env::consts::ARCH, fmt, path::PathBuf, str::FromStr, sync::LazyLock};
use directories::BaseDirs; use directories::BaseDirs;
use once_cell::sync::Lazy;
static HOME_DIR: Lazy<PathBuf> = Lazy::new(|| { static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
BaseDirs::new() BaseDirs::new()
.expect("could not find home directory") .expect("could not find home directory")
.home_dir() .home_dir()
.to_path_buf() .to_path_buf()
}); });
pub static CACHE_DIR: Lazy<PathBuf> = Lazy::new(|| HOME_DIR.join(".lune").join("target")); pub static CACHE_DIR: LazyLock<PathBuf> = LazyLock::new(|| HOME_DIR.join(".lune").join("target"));
/** /**
A target operating system supported by Lune A target operating system supported by Lune

View file

@ -81,7 +81,7 @@ impl ReplCommand {
eprintln!("REPL ERROR: {err}"); eprintln!("REPL ERROR: {err}");
return Ok(ExitCode::FAILURE); return Ok(ExitCode::FAILURE);
} }
}; }
// TODO: Preserve context here somehow? // TODO: Preserve context here somehow?
let eval_result = lune_instance.run("REPL", &source_code).await; let eval_result = lune_instance.run("REPL", &source_code).await;
@ -97,7 +97,7 @@ impl ReplCommand {
eprintln!("{err}"); eprintln!("{err}");
} }
} }
}; }
} }
repl.save_history(history_file_path)?; repl.save_history(history_file_path)?;

View file

@ -1,16 +1,16 @@
use std::{ use std::{
fs::Metadata, fs::Metadata,
path::{PathBuf, MAIN_SEPARATOR}, path::{PathBuf, MAIN_SEPARATOR},
sync::LazyLock,
}; };
use anyhow::{anyhow, bail, Result}; use anyhow::{anyhow, bail, Result};
use console::style; use console::style;
use directories::UserDirs; use directories::UserDirs;
use once_cell::sync::Lazy;
const LUNE_COMMENT_PREFIX: &str = "-->"; const LUNE_COMMENT_PREFIX: &str = "-->";
static ERR_MESSAGE_HELP_NOTE: Lazy<String> = Lazy::new(|| { static ERR_MESSAGE_HELP_NOTE: LazyLock<String> = LazyLock::new(|| {
format!( format!(
"To run this file, either:\n{}\n{}", "To run this file, either:\n{}\n{}",
format_args!( format_args!(

View file

@ -1,17 +1,16 @@
#![allow(clippy::match_same_arms)] #![allow(clippy::match_same_arms)]
use std::{cmp::Ordering, ffi::OsStr, fmt::Write as _, path::PathBuf}; use std::{cmp::Ordering, ffi::OsStr, fmt::Write as _, path::PathBuf, sync::LazyLock};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use console::Style; use console::Style;
use directories::UserDirs; use directories::UserDirs;
use once_cell::sync::Lazy;
use tokio::{fs, io}; use tokio::{fs, io};
use super::files::{discover_script_path, parse_lune_description_from_file}; use super::files::{discover_script_path, parse_lune_description_from_file};
pub static COLOR_BLUE: Lazy<Style> = Lazy::new(|| Style::new().blue()); pub static COLOR_BLUE: LazyLock<Style> = LazyLock::new(|| Style::new().blue());
pub static STYLE_DIM: Lazy<Style> = Lazy::new(|| Style::new().dim()); pub static STYLE_DIM: LazyLock<Style> = LazyLock::new(|| Style::new().dim());
pub async fn find_lune_scripts(in_home_dir: bool) -> Result<Vec<(String, String)>> { pub async fn find_lune_scripts(in_home_dir: bool) -> Result<Vec<(String, String)>> {
let base_path = if in_home_dir { let base_path = if in_home_dir {

View file

@ -1,12 +1,11 @@
use std::{env, path::PathBuf}; use std::{env, path::PathBuf, sync::LazyLock};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use mlua::Compiler as LuaCompiler; use mlua::Compiler as LuaCompiler;
use once_cell::sync::Lazy;
use tokio::fs; use tokio::fs;
pub static CURRENT_EXE: Lazy<PathBuf> = pub static CURRENT_EXE: LazyLock<PathBuf> =
Lazy::new(|| env::current_exe().expect("failed to get current exe")); LazyLock::new(|| env::current_exe().expect("failed to get current exe"));
const MAGIC: &[u8; 8] = b"cr3sc3nt"; const MAGIC: &[u8; 8] = b"cr3sc3nt";
/* /*