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>() {
return lua.create_userdata(*this * *vec);
}
};
}
Err(LuaError::FromLuaConversionError {
from: rhs.type_name(),
to: "userdata",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,14 +1,15 @@
use std::fmt;
use std::str::FromStr;
use std::sync::Arc;
use std::{
fmt,
str::FromStr,
sync::{Arc, LazyLock},
};
use console::style;
use mlua::prelude::*;
use once_cell::sync::Lazy;
use super::StackTrace;
static STYLED_STACK_BEGIN: Lazy<String> = Lazy::new(|| {
static STYLED_STACK_BEGIN: LazyLock<String> = LazyLock::new(|| {
format!(
"{}{}{}",
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!(
"{}{}{}",
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 mlua::prelude::*;
use once_cell::sync::Lazy;
use parking_lot::ReentrantMutex;
mod basic;
@ -18,7 +20,8 @@ pub use self::config::ValueFormatConfig;
// NOTE: Since the setting for colors being enabled is 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.
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.

View file

@ -1,9 +1,10 @@
use std::sync::LazyLock;
use console::Style;
use once_cell::sync::Lazy;
pub static COLOR_GREEN: Lazy<Style> = Lazy::new(|| Style::new().green());
pub static COLOR_YELLOW: Lazy<Style> = Lazy::new(|| Style::new().yellow());
pub static COLOR_MAGENTA: Lazy<Style> = Lazy::new(|| Style::new().magenta());
pub static COLOR_CYAN: Lazy<Style> = Lazy::new(|| Style::new().cyan());
pub static COLOR_GREEN: LazyLock<Style> = LazyLock::new(|| Style::new().green());
pub static COLOR_YELLOW: LazyLock<Style> = LazyLock::new(|| Style::new().yellow());
pub static COLOR_MAGENTA: LazyLock<Style> = LazyLock::new(|| Style::new().magenta());
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::{
env::{current_dir, current_exe},
path::{Path, PathBuf, MAIN_SEPARATOR},
sync::Arc,
sync::{Arc, LazyLock},
};
use once_cell::sync::Lazy;
use path_clean::PathClean;
static CWD: Lazy<Arc<Path>> = Lazy::new(create_cwd);
static EXE: Lazy<Arc<Path>> = Lazy::new(create_exe);
static CWD: LazyLock<Arc<Path>> = LazyLock::new(create_cwd);
static EXE: LazyLock<Arc<Path>> = LazyLock::new(create_exe);
fn create_cwd() -> Arc<Path> {
let mut cwd = current_dir()

View file

@ -1,10 +1,9 @@
use std::sync::Arc;
use std::sync::{Arc, LazyLock};
use mlua::prelude::*;
use once_cell::sync::Lazy;
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`.

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 once_cell::sync::Lazy;
static HOME_DIR: Lazy<PathBuf> = Lazy::new(|| {
static HOME_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
BaseDirs::new()
.expect("could not find home directory")
.home_dir()
.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

View file

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

View file

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

View file

@ -1,17 +1,16 @@
#![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 console::Style;
use directories::UserDirs;
use once_cell::sync::Lazy;
use tokio::{fs, io};
use super::files::{discover_script_path, parse_lune_description_from_file};
pub static COLOR_BLUE: Lazy<Style> = Lazy::new(|| Style::new().blue());
pub static STYLE_DIM: Lazy<Style> = Lazy::new(|| Style::new().dim());
pub static COLOR_BLUE: LazyLock<Style> = LazyLock::new(|| Style::new().blue());
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)>> {
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 mlua::Compiler as LuaCompiler;
use once_cell::sync::Lazy;
use tokio::fs;
pub static CURRENT_EXE: Lazy<PathBuf> =
Lazy::new(|| env::current_exe().expect("failed to get current exe"));
pub static CURRENT_EXE: LazyLock<PathBuf> =
LazyLock::new(|| env::current_exe().expect("failed to get current exe"));
const MAGIC: &[u8; 8] = b"cr3sc3nt";
/*