Satisfy clippy.
This commit is contained in:
parent
c58fe87107
commit
75718a5a8b
@ -93,7 +93,7 @@ impl OpAssignment {
|
||||
#[inline(always)]
|
||||
pub fn new_op_assignment_from_base(name: &str, pos: Position) -> Self {
|
||||
let op = Token::lookup_symbol_from_syntax(name).expect("operator");
|
||||
Self::new_op_assignment_from_base_token(op, pos)
|
||||
Self::new_op_assignment_from_base_token(&op, pos)
|
||||
}
|
||||
/// Convert a [`Token`] into a new [`OpAssignment`].
|
||||
///
|
||||
@ -102,7 +102,7 @@ impl OpAssignment {
|
||||
/// Panics if the token is cannot be converted into an op-assignment operator.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new_op_assignment_from_base_token(op: Token, pos: Position) -> Self {
|
||||
pub fn new_op_assignment_from_base_token(op: &Token, pos: Position) -> Self {
|
||||
Self::new_op_assignment_from_token(op.convert_to_op_assignment().expect("operator"), pos)
|
||||
}
|
||||
}
|
||||
|
@ -166,10 +166,7 @@ fn load_script(engine: &Engine) -> (rhai::AST, String) {
|
||||
|
||||
let filename = match Path::new(&filename).canonicalize() {
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
"\x1b[31mError script file path: {}\n{}\x1b[39m",
|
||||
filename, err
|
||||
);
|
||||
eprintln!("\x1b[31mError script file path: {filename}\n{err}\x1b[39m");
|
||||
exit(1);
|
||||
}
|
||||
Ok(f) => {
|
||||
@ -315,7 +312,7 @@ fn debug_callback(
|
||||
}
|
||||
["node"] => {
|
||||
if pos.is_none() {
|
||||
println!("{:?}", node);
|
||||
println!("{node:?}");
|
||||
} else {
|
||||
match source {
|
||||
Some(source) => println!("{node:?} {source} @ {pos:?}"),
|
||||
@ -400,7 +397,7 @@ fn debug_callback(
|
||||
#[cfg(not(feature = "no_position"))]
|
||||
rhai::debugger::BreakPoint::AtPosition { pos, .. } => {
|
||||
let line_num = format!("[{}] line ", i + 1);
|
||||
print!("{}", line_num);
|
||||
print!("{line_num}");
|
||||
print_source(lines, *pos, line_num.len(), (0, 0));
|
||||
}
|
||||
_ => println!("[{}] {bp}", i + 1),
|
||||
|
@ -495,13 +495,13 @@ impl Engine {
|
||||
///
|
||||
/// It is up to the [`Engine`] to reactivate the debugger.
|
||||
#[inline]
|
||||
pub(crate) fn run_debugger_raw<'a>(
|
||||
pub(crate) fn run_debugger_raw(
|
||||
&self,
|
||||
global: &mut GlobalRuntimeState,
|
||||
caches: &mut Caches,
|
||||
scope: &mut Scope,
|
||||
this_ptr: Option<&mut Dynamic>,
|
||||
node: ASTNode<'a>,
|
||||
node: ASTNode,
|
||||
event: DebuggerEvent,
|
||||
) -> Result<Option<DebuggerStatus>, Box<crate::EvalAltResult>> {
|
||||
if let Some(ref x) = self.debugger_interface {
|
||||
|
@ -80,11 +80,14 @@
|
||||
#![allow(clippy::upper_case_acronyms)]
|
||||
#![allow(clippy::match_same_arms)]
|
||||
// The lints below can be turned off to reduce signal/noise ratio
|
||||
// #![allow(clippy::too_many_lines)]
|
||||
// #![allow(clippy::let_underscore_drop)]
|
||||
#![allow(clippy::too_many_lines)]
|
||||
#![allow(clippy::let_underscore_drop)]
|
||||
#![allow(clippy::absurd_extreme_comparisons)]
|
||||
#![allow(clippy::unnecessary_cast)]
|
||||
// #![allow(clippy::wildcard_imports)]
|
||||
#![allow(clippy::wildcard_imports)]
|
||||
#![allow(clippy::no_effect_underscore_binding)]
|
||||
#![allow(clippy::semicolon_if_nothing_returned)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
|
||||
#[cfg(feature = "no_std")]
|
||||
extern crate alloc;
|
||||
|
@ -233,7 +233,7 @@ impl fmt::Debug for Module {
|
||||
.modules
|
||||
.as_deref()
|
||||
.into_iter()
|
||||
.flat_map(|m| m.keys())
|
||||
.flat_map(BTreeMap::keys)
|
||||
.map(SmartString::as_str)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
@ -2202,7 +2202,7 @@ impl Module {
|
||||
environ: ref mut e, ..
|
||||
} = f.func
|
||||
{
|
||||
*e = Some(environ.clone())
|
||||
*e = Some(environ.clone());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -513,11 +513,13 @@ pub mod blob_functions {
|
||||
///
|
||||
/// print(b); // prints "[030405]"
|
||||
/// ```
|
||||
#[allow(clippy::cast_sign_loss, clippy::needless_pass_by_value)]
|
||||
#[allow(clippy::cast_sign_loss, clippy::needless_pass_by_value, clippy::cast_possible_truncation)]
|
||||
pub fn chop(blob: &mut Blob, len: INT) {
|
||||
if !blob.is_empty() {
|
||||
if len <= 0 {
|
||||
blob.clear();
|
||||
} else if len > MAX_USIZE_INT {
|
||||
// len > BLOB length
|
||||
} else if (len as usize) < blob.len() {
|
||||
blob.drain(0..blob.len() - len as usize);
|
||||
}
|
||||
|
@ -109,11 +109,11 @@ mod core_functions {
|
||||
/// ```
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
pub fn sleep(seconds: INT) {
|
||||
if seconds <= 0 {
|
||||
return;
|
||||
}
|
||||
if seconds > 0 {
|
||||
#[allow(clippy::cast_sign_loss)]
|
||||
std::thread::sleep(std::time::Duration::from_secs(seconds as u64));
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse a JSON string into a value.
|
||||
///
|
||||
@ -142,23 +142,23 @@ mod reflection_functions {
|
||||
|
||||
/// Return an array of object maps containing metadata of all script-defined functions.
|
||||
pub fn get_fn_metadata_list(ctx: NativeCallContext) -> Array {
|
||||
collect_fn_metadata(ctx, |_, _, _, _, _| true)
|
||||
collect_fn_metadata(&ctx, |_, _, _, _, _| true)
|
||||
}
|
||||
/// Return an array of object maps containing metadata of all script-defined functions
|
||||
/// matching the specified name.
|
||||
#[rhai_fn(name = "get_fn_metadata_list")]
|
||||
pub fn get_fn_metadata(ctx: NativeCallContext, name: &str) -> Array {
|
||||
collect_fn_metadata(ctx, |_, _, n, _, _| n == name)
|
||||
collect_fn_metadata(&ctx, |_, _, n, _, _| n == name)
|
||||
}
|
||||
/// Return an array of object maps containing metadata of all script-defined functions
|
||||
/// matching the specified name and arity (number of parameters).
|
||||
#[rhai_fn(name = "get_fn_metadata_list")]
|
||||
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
||||
pub fn get_fn_metadata2(ctx: NativeCallContext, name: &str, params: INT) -> Array {
|
||||
if !(0..=crate::MAX_USIZE_INT).contains(¶ms) {
|
||||
Array::new()
|
||||
if (0..=crate::MAX_USIZE_INT).contains(¶ms) {
|
||||
collect_fn_metadata(&ctx, |_, _, n, p, _| p == (params as usize) && n == name)
|
||||
} else {
|
||||
collect_fn_metadata(ctx, |_, _, n, p, _| p == (params as usize) && n == name)
|
||||
Array::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,7 +167,7 @@ mod reflection_functions {
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
fn collect_fn_metadata(
|
||||
ctx: NativeCallContext,
|
||||
ctx: &NativeCallContext,
|
||||
filter: impl Fn(FnNamespace, FnAccess, &str, usize, &crate::Shared<crate::ast::ScriptFnDef>) -> bool
|
||||
+ Copy,
|
||||
) -> crate::Array {
|
||||
|
@ -3560,7 +3560,9 @@ impl Engine {
|
||||
// try { try_block } catch ( var ) { catch_block }
|
||||
let branch = self.parse_block(input, state, lib, settings)?.into();
|
||||
|
||||
let expr = if !catch_var.is_empty() {
|
||||
let expr = if catch_var.is_empty() {
|
||||
Expr::Unit(catch_var.pos)
|
||||
} else {
|
||||
// Remove the error variable from the stack
|
||||
state.stack.as_deref_mut().unwrap().pop();
|
||||
|
||||
@ -3569,12 +3571,10 @@ impl Engine {
|
||||
None,
|
||||
catch_var.pos,
|
||||
)
|
||||
} else {
|
||||
Expr::Unit(catch_var.pos)
|
||||
};
|
||||
|
||||
Ok(Stmt::TryCatch(
|
||||
FlowControl { body, expr, branch }.into(),
|
||||
FlowControl { expr, body, branch }.into(),
|
||||
settings.pos,
|
||||
))
|
||||
}
|
||||
|
@ -1830,11 +1830,11 @@ fn get_next_token_inner(
|
||||
return Some((Token::NotIn, start_pos));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
stream.unget('i');
|
||||
return Some((Token::Bang, start_pos));
|
||||
}
|
||||
}
|
||||
('!', '=') => {
|
||||
eat_next_and_advance(stream, pos);
|
||||
|
||||
@ -2137,7 +2137,7 @@ impl InputStream for MultiInputsStream<'_> {
|
||||
}
|
||||
fn peek_next(&mut self) -> Option<char> {
|
||||
if let ch @ Some(..) = self.buf.last() {
|
||||
return ch.cloned();
|
||||
return ch.copied();
|
||||
}
|
||||
|
||||
loop {
|
||||
|
Loading…
Reference in New Issue
Block a user