Shut up clippy.
This commit is contained in:
@@ -989,7 +989,7 @@ impl Engine {
|
||||
} else {
|
||||
let abs_index = index.unsigned_abs();
|
||||
|
||||
if abs_index as u64 >= usize::MAX as u64 {
|
||||
if abs_index as u64 > usize::MAX as u64 {
|
||||
return Err(
|
||||
ERR::ErrorStringBounds(s.chars().count(), index, idx_pos).into()
|
||||
);
|
||||
|
@@ -397,7 +397,7 @@ impl Debugger {
|
||||
/// Get the custom state.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn state(&self) -> &Dynamic {
|
||||
pub const fn state(&self) -> &Dynamic {
|
||||
&self.state
|
||||
}
|
||||
/// Get a mutable reference to the custom state.
|
||||
|
@@ -144,11 +144,10 @@ impl Engine {
|
||||
let (index, var_pos) = match expr {
|
||||
// Check if the variable is `this`
|
||||
Expr::Variable(v, None, pos) if v.0.is_none() && v.3 == KEYWORD_THIS => {
|
||||
return if let Some(val) = this_ptr {
|
||||
Ok(((*val).into(), *pos))
|
||||
} else {
|
||||
Err(ERR::ErrorUnboundThis(*pos).into())
|
||||
}
|
||||
return this_ptr.as_mut().map_or_else(
|
||||
|| Err(ERR::ErrorUnboundThis(*pos).into()),
|
||||
|val| Ok(((*val).into(), *pos)),
|
||||
)
|
||||
}
|
||||
_ if global.always_search_scope => (0, expr.start_position()),
|
||||
Expr::Variable(.., Some(i), pos) => (i.get() as usize, *pos),
|
||||
|
@@ -484,12 +484,10 @@ impl Engine {
|
||||
self.eval_expr(scope, global, caches, lib, this_ptr, expr, level)
|
||||
} else if let Ok(None) = expr_result {
|
||||
// Default match clause
|
||||
if let Some(index) = def_case {
|
||||
let def_expr = &expressions[*index].expr;
|
||||
def_case.as_ref().map_or(Ok(Dynamic::UNIT), |&index| {
|
||||
let def_expr = &expressions[index].expr;
|
||||
self.eval_expr(scope, global, caches, lib, this_ptr, def_expr, level)
|
||||
} else {
|
||||
Ok(Dynamic::UNIT)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
expr_result.map(|_| Dynamic::UNIT)
|
||||
}
|
||||
|
@@ -15,7 +15,12 @@ use std::prelude::v1::*;
|
||||
#[allow(dead_code)]
|
||||
pub fn calc_offset_len(length: usize, start: crate::INT, len: crate::INT) -> (usize, usize) {
|
||||
let start = if start < 0 {
|
||||
length - usize::min(start.unsigned_abs() as usize, length)
|
||||
let abs_start = start.unsigned_abs();
|
||||
if abs_start as u64 > crate::MAX_USIZE_INT as u64 {
|
||||
0
|
||||
} else {
|
||||
length - usize::min(abs_start as usize, length)
|
||||
}
|
||||
} else if start > crate::MAX_USIZE_INT || start as usize >= length {
|
||||
return (length, 0);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user