Clean up more clippy.
This commit is contained in:
@@ -147,10 +147,10 @@ impl fmt::Display for BreakPoint {
|
||||
pos,
|
||||
enabled,
|
||||
} => {
|
||||
if !source.is_empty() {
|
||||
write!(f, "{} @ {:?}", source, pos)?;
|
||||
} else {
|
||||
if source.is_empty() {
|
||||
write!(f, "@ {:?}", pos)?;
|
||||
} else {
|
||||
write!(f, "{} @ {:?}", source, pos)?;
|
||||
}
|
||||
if !*enabled {
|
||||
f.write_str(" (disabled)")?;
|
||||
@@ -201,6 +201,7 @@ impl fmt::Display for BreakPoint {
|
||||
impl BreakPoint {
|
||||
/// Is this [`BreakPoint`] enabled?
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn is_enabled(&self) -> bool {
|
||||
match self {
|
||||
#[cfg(not(feature = "no_position"))]
|
||||
|
@@ -113,7 +113,7 @@ impl<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, '
|
||||
/// Get an iterator over the namespaces containing definition of all script-defined functions.
|
||||
#[inline]
|
||||
pub fn iter_namespaces(&self) -> impl Iterator<Item = &Module> {
|
||||
self.lib.iter().cloned()
|
||||
self.lib.iter().copied()
|
||||
}
|
||||
/// _(internals)_ The current set of namespaces containing definitions of all script-defined functions.
|
||||
/// Exported under the `internals` feature only.
|
||||
@@ -133,7 +133,7 @@ impl<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, '
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn this_ptr_mut(&mut self) -> &mut Option<&'pt mut Dynamic> {
|
||||
&mut self.this_ptr
|
||||
self.this_ptr
|
||||
}
|
||||
/// The current nesting level of function calls.
|
||||
#[inline(always)]
|
||||
|
@@ -149,7 +149,7 @@ impl Engine {
|
||||
}
|
||||
_ if global.always_search_scope => (0, expr.start_position()),
|
||||
Expr::Variable(.., Some(i), pos) => (i.get() as usize, *pos),
|
||||
Expr::Variable(v, None, pos) => (v.0.map(NonZeroUsize::get).unwrap_or(0), *pos),
|
||||
Expr::Variable(v, None, pos) => (v.0.map_or(0, NonZeroUsize::get), *pos),
|
||||
_ => unreachable!("Expr::Variable expected but gets {:?}", expr),
|
||||
};
|
||||
|
||||
@@ -485,7 +485,7 @@ impl Engine {
|
||||
let custom_def = self.custom_syntax.get(key_token).ok_or_else(|| {
|
||||
Box::new(ERR::ErrorCustomSyntax(
|
||||
format!("Invalid custom syntax prefix: {}", key_token),
|
||||
custom.tokens.iter().map(|s| s.to_string()).collect(),
|
||||
custom.tokens.iter().map(<_>::to_string).collect(),
|
||||
*pos,
|
||||
))
|
||||
})?;
|
||||
|
@@ -284,26 +284,26 @@ impl GlobalRuntimeState<'_> {
|
||||
#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))]
|
||||
#[must_use]
|
||||
pub(crate) fn hash_idx_get(&mut self) -> u64 {
|
||||
if self.fn_hash_indexing != (0, 0) {
|
||||
self.fn_hash_indexing.0
|
||||
} else {
|
||||
if self.fn_hash_indexing == (0, 0) {
|
||||
let n1 = crate::calc_fn_hash(crate::engine::FN_IDX_GET, 2);
|
||||
let n2 = crate::calc_fn_hash(crate::engine::FN_IDX_SET, 3);
|
||||
self.fn_hash_indexing = (n1, n2);
|
||||
n1
|
||||
} else {
|
||||
self.fn_hash_indexing.0
|
||||
}
|
||||
}
|
||||
/// Get the pre-calculated index setter hash.
|
||||
#[cfg(any(not(feature = "no_index"), not(feature = "no_object")))]
|
||||
#[must_use]
|
||||
pub(crate) fn hash_idx_set(&mut self) -> u64 {
|
||||
if self.fn_hash_indexing != (0, 0) {
|
||||
self.fn_hash_indexing.1
|
||||
} else {
|
||||
if self.fn_hash_indexing == (0, 0) {
|
||||
let n1 = crate::calc_fn_hash(crate::engine::FN_IDX_GET, 2);
|
||||
let n2 = crate::calc_fn_hash(crate::engine::FN_IDX_SET, 3);
|
||||
self.fn_hash_indexing = (n1, n2);
|
||||
n2
|
||||
} else {
|
||||
self.fn_hash_indexing.1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -368,21 +368,21 @@ impl Engine {
|
||||
|
||||
match guard_val {
|
||||
Ok(true) => {
|
||||
if !if_block.is_empty() {
|
||||
if if_block.is_empty() {
|
||||
Ok(Dynamic::UNIT)
|
||||
} else {
|
||||
self.eval_stmt_block(
|
||||
scope, global, caches, lib, this_ptr, if_block, true, level,
|
||||
)
|
||||
} else {
|
||||
Ok(Dynamic::UNIT)
|
||||
}
|
||||
}
|
||||
Ok(false) => {
|
||||
if !else_block.is_empty() {
|
||||
if else_block.is_empty() {
|
||||
Ok(Dynamic::UNIT)
|
||||
} else {
|
||||
self.eval_stmt_block(
|
||||
scope, global, caches, lib, this_ptr, else_block, true, level,
|
||||
)
|
||||
} else {
|
||||
Ok(Dynamic::UNIT)
|
||||
}
|
||||
}
|
||||
err => err.map(Into::into),
|
||||
@@ -510,7 +510,10 @@ impl Engine {
|
||||
Stmt::While(x, ..) if matches!(x.0, Expr::Unit(..)) => loop {
|
||||
let (.., body) = &**x;
|
||||
|
||||
if !body.is_empty() {
|
||||
if body.is_empty() {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
self.inc_operations(&mut global.num_operations, body.position())?;
|
||||
} else {
|
||||
match self
|
||||
.eval_stmt_block(scope, global, caches, lib, this_ptr, body, true, level)
|
||||
{
|
||||
@@ -521,9 +524,6 @@ impl Engine {
|
||||
_ => break Err(err),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
self.inc_operations(&mut global.num_operations, body.position())?;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -624,11 +624,11 @@ impl Engine {
|
||||
if let Some(func) = func {
|
||||
// Add the loop variables
|
||||
let orig_scope_len = scope.len();
|
||||
let counter_index = if !counter.is_empty() {
|
||||
let counter_index = if counter.is_empty() {
|
||||
usize::MAX
|
||||
} else {
|
||||
scope.push(counter.name.clone(), 0 as INT);
|
||||
scope.len() - 1
|
||||
} else {
|
||||
usize::MAX
|
||||
};
|
||||
|
||||
scope.push(var_name.name.clone(), ());
|
||||
@@ -979,13 +979,13 @@ impl Engine {
|
||||
|
||||
if let Ok(module) = module_result {
|
||||
if !export.is_empty() {
|
||||
if !module.is_indexed() {
|
||||
if module.is_indexed() {
|
||||
global.push_import(export.name.clone(), module);
|
||||
} else {
|
||||
// Index the module (making a clone copy if necessary) if it is not indexed
|
||||
let mut m = crate::func::shared_take_or_clone(module);
|
||||
m.build_index();
|
||||
global.push_import(export.name.clone(), m);
|
||||
} else {
|
||||
global.push_import(export.name.clone(), module);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user