fix: default clippy lints

This commit is contained in:
Mathieu Lala
2022-12-30 18:07:39 +01:00
parent 4c2630b71f
commit 9af5b1c78e
42 changed files with 191 additions and 190 deletions

View File

@@ -245,16 +245,16 @@ impl Engine {
g.source = orig_source;
});
self.eval_global_statements(global, caches, scope, ast.statements())
.and_then(|r| {
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let node = &crate::ast::Stmt::Noop(Position::NONE);
self.run_debugger(global, caches, scope, None, node)?;
}
Ok(r)
})
let r = self.eval_global_statements(global, caches, scope, ast.statements())?;
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let node = &crate::ast::Stmt::Noop(Position::NONE);
self.run_debugger(global, caches, scope, None, node)?;
}
Ok(r)
}
}

View File

@@ -97,7 +97,7 @@ impl Engine {
///
/// // Compile a script to an AST and store it for later evaluation.
/// // Notice that a PathBuf is required which can easily be constructed from a string.
/// let ast = engine.compile_file_with_scope(&mut scope, "script.rhai".into())?;
/// let ast = engine.compile_file_with_scope(&scope, "script.rhai".into())?;
///
/// let result = engine.eval_ast::<i64>(&ast)?;
/// # }

View File

@@ -126,16 +126,16 @@ impl Engine {
global.embedded_module_resolver = ast.resolver().cloned();
}
self.eval_global_statements(global, caches, scope, ast.statements())
.and_then(|_| {
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let node = &crate::ast::Stmt::Noop(crate::Position::NONE);
self.run_debugger(global, caches, scope, None, node)?;
}
Ok(())
})
let _ = self.eval_global_statements(global, caches, scope, ast.statements())?;
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
global.debugger_mut().status = crate::eval::DebuggerStatus::Terminate;
let node = &crate::ast::Stmt::Noop(crate::Position::NONE);
self.run_debugger(global, caches, scope, None, node)?;
}
Ok(())
}
}

View File

@@ -287,6 +287,7 @@ pub enum Expr {
Array(Box<StaticVec<Expr>>, Position),
/// #{ name:expr, ... }
Map(
#[allow(clippy::type_complexity)]
Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>,
Position,
),
@@ -304,6 +305,7 @@ pub enum Expr {
),
/// Property access - ((getter, hash), (setter, hash), prop)
Property(
#[allow(clippy::type_complexity)]
Box<(
(ImmutableString, u64),
(ImmutableString, u64),

View File

@@ -103,11 +103,11 @@ impl Dynamic {
pub(crate) fn calc_data_sizes(&self, _top: bool) -> (usize, usize, usize) {
match self.0 {
#[cfg(not(feature = "no_index"))]
Union::Array(ref arr, ..) => Self::calc_array_sizes(&**arr),
Union::Array(ref arr, ..) => Self::calc_array_sizes(arr),
#[cfg(not(feature = "no_index"))]
Union::Blob(ref blob, ..) => (blob.len(), 0, 0),
#[cfg(not(feature = "no_object"))]
Union::Map(ref map, ..) => Self::calc_map_sizes(&**map),
Union::Map(ref map, ..) => Self::calc_map_sizes(map),
Union::Str(ref s, ..) => (0, 0, s.len()),
#[cfg(not(feature = "no_closure"))]
Union::Shared(..) if _top => self.read_lock::<Self>().unwrap().calc_data_sizes(true),

View File

@@ -28,7 +28,7 @@ impl Engine {
global: &mut GlobalRuntimeState,
caches: &mut Caches,
scope: &mut Scope,
mut this_ptr: Option<&mut Dynamic>,
this_ptr: Option<&mut Dynamic>,
_environ: Option<&EncapsulatedEnviron>,
fn_def: &ScriptFnDef,
args: &mut FnCallArgs,
@@ -108,19 +108,12 @@ impl Engine {
#[cfg(feature = "debugging")]
if self.is_debugger_registered() {
let node = crate::ast::Stmt::Noop(fn_def.body.position());
self.run_debugger(global, caches, scope, this_ptr.as_deref_mut(), &node)?;
self.run_debugger(global, caches, scope, this_ptr, &node)?;
}
// Evaluate the function
let mut _result: RhaiResult = self
.eval_stmt_block(
global,
caches,
scope,
this_ptr.as_deref_mut(),
&fn_def.body,
rewind_scope,
)
.eval_stmt_block(global, caches, scope, this_ptr, &fn_def.body, rewind_scope)
.or_else(|err| match *err {
// Convert return statement to return value
ERR::Return(x, ..) => Ok(x),

View File

@@ -42,7 +42,7 @@
//!
//! # #[cfg(not(feature = "no_std"))]
//! # #[cfg(not(target_family = "wasm"))]
//! #
//! #
//! // Evaluate the script, expecting a 'bool' result
//! let result: bool = engine.eval_file("my_script.rhai".into())?;
//!
@@ -82,8 +82,8 @@
// The lints below can be turned off to reduce signal/noise ratio
// #![allow(clippy::too_many_lines)]
// #![allow(clippy::let_underscore_drop)]
// #![allow(clippy::absurd_extreme_comparisons)]
// #![allow(clippy::unnecessary_cast)]
#![allow(clippy::absurd_extreme_comparisons)]
#![allow(clippy::unnecessary_cast)]
// #![allow(clippy::wildcard_imports)]
#[cfg(feature = "no_std")]

View File

@@ -141,14 +141,12 @@ mod print_debug_functions {
/// Return the empty string.
#[rhai_fn(name = "print", name = "to_string")]
pub fn print_unit(ctx: NativeCallContext, unit: ()) -> ImmutableString {
let _ = unit;
pub fn print_unit(ctx: NativeCallContext, _unit: ()) -> ImmutableString {
ctx.engine().const_empty_string()
}
/// Convert the unit into a string in debug format.
#[rhai_fn(name = "debug", name = "to_debug")]
pub fn debug_unit(unit: ()) -> ImmutableString {
let _ = unit;
pub fn debug_unit(_unit: ()) -> ImmutableString {
"()".into()
}

View File

@@ -84,8 +84,7 @@ mod string_functions {
}
#[rhai_fn(name = "+")]
pub fn add_append_unit(string: ImmutableString, item: ()) -> ImmutableString {
let _ = item;
pub fn add_append_unit(string: ImmutableString, _item: ()) -> ImmutableString {
string
}
#[rhai_fn(name = "+")]
@@ -102,9 +101,8 @@ mod string_functions {
*string += character;
}
#[rhai_fn(name = "+=")]
pub fn add_assign_append_unit(string: &mut ImmutableString, item: ()) {
pub fn add_assign_append_unit(string: &mut ImmutableString, _item: ()) {
let _ = string;
let _ = item;
}
#[cfg(not(feature = "no_index"))]

View File

@@ -99,6 +99,7 @@ impl FnPtr {
#[cfg(not(feature = "no_function"))]
#[inline(always)]
#[must_use]
#[allow(clippy::type_complexity)]
pub(crate) fn take_data(
self,
) -> (