pull main & udpate lint

This commit is contained in:
Mathieu Lala
2023-02-05 17:59:02 +01:00
parent 097fa1f4e3
commit 9bdf3c290d
12 changed files with 44 additions and 41 deletions

View File

@@ -212,12 +212,12 @@ impl Engine {
}
/// Evaluate an [`AST`] with own scope, returning the result value or an error.
#[inline]
pub(crate) fn eval_ast_with_scope_raw<'a>(
pub(crate) fn eval_ast_with_scope_raw(
&self,
global: &mut GlobalRuntimeState,
caches: &mut Caches,
scope: &mut Scope,
ast: &'a AST,
ast: &AST,
) -> RhaiResult {
let orig_source = mem::replace(&mut global.source, ast.source_raw().cloned());

View File

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

View File

@@ -185,7 +185,8 @@ const INT_BYTES: usize = std::mem::size_of::<INT>();
/// Not available under `no_float`.
///
/// If the `f32_float` feature is enabled, this will be [`f32`] instead.
#[cfg(all(not(feature = "no_float"), not(feature = "f32_float")))]
#[cfg(not(feature = "no_float"))]
#[cfg(not(feature = "f32_float"))]
pub type FLOAT = f64;
/// The system floating-point type.
@@ -194,13 +195,15 @@ pub type FLOAT = f64;
/// Not available under `no_float`.
///
/// If the `f32_float` feature is not used, this will be `f64` instead.
#[cfg(all(not(feature = "no_float"), feature = "f32_float"))]
#[cfg(not(feature = "no_float"))]
#[cfg(feature = "f32_float")]
pub type FLOAT = f32;
/// Number of bytes that make up a [`FLOAT`].
///
/// It is 8 unless the `f32_float` feature is enabled when it will be 4.
#[cfg(all(not(feature = "no_float"), not(feature = "no_index")))]
#[cfg(not(feature = "no_float"))]
#[cfg(not(feature = "no_index"))]
const FLOAT_BYTES: usize = std::mem::size_of::<FLOAT>();
/// An exclusive integer range.
@@ -213,7 +216,8 @@ type InclusiveRange = std::ops::RangeInclusive<INT>;
pub use api::build_type::{CustomType, TypeBuilder};
#[cfg(not(feature = "no_custom_syntax"))]
pub use api::custom_syntax::Expression;
#[cfg(all(not(feature = "no_std"), not(target_family = "wasm")))]
#[cfg(not(feature = "no_std"))]
#[cfg(not(target_family = "wasm"))]
pub use api::files::{eval_file, run_file};
pub use api::{eval::eval, events::VarDefInfo, run::run};
pub use ast::{FnAccess, AST};
@@ -333,10 +337,12 @@ pub use ast::{
Ident, OpAssignment, RangeCase, ScriptFnDef, Stmt, StmtBlock, SwitchCasesCollection,
};
#[cfg(all(feature = "internals", not(feature = "no_custom_syntax")))]
#[cfg(feature = "internals")]
#[cfg(not(feature = "no_custom_syntax"))]
pub use ast::CustomExpr;
#[cfg(all(feature = "internals", not(feature = "no_module")))]
#[cfg(feature = "internals")]
#[cfg(not(feature = "no_module"))]
pub use ast::Namespace;
#[cfg(feature = "internals")]
@@ -349,7 +355,8 @@ pub use eval::{Caches, FnResolutionCache, FnResolutionCacheEntry, GlobalRuntimeS
#[allow(deprecated)]
pub use func::{locked_read, locked_write, CallableFunction, NativeCallContextStore};
#[cfg(all(feature = "internals", feature = "metadata"))]
#[cfg(feature = "internals")]
#[cfg(feature = "metadata")]
pub use api::definitions::Definitions;
/// Number of items to keep inline for [`StaticVec`].
@@ -452,26 +459,34 @@ type SmartString = smartstring::SmartString<smartstring::LazyCompact>;
// Compiler guards against mutually-exclusive feature flags
#[cfg(all(feature = "no_float", feature = "f32_float"))]
#[cfg(feature = "no_float")]
#[cfg(feature = "f32_float")]
compile_error!("`f32_float` cannot be used with `no_float`");
#[cfg(all(feature = "only_i32", feature = "only_i64"))]
#[cfg(feature = "only_i32")]
#[cfg(feature = "only_i64")]
compile_error!("`only_i32` and `only_i64` cannot be used together");
#[cfg(all(feature = "no_std", feature = "wasm-bindgen"))]
#[cfg(feature = "no_std")]
#[cfg(feature = "wasm-bindgen")]
compile_error!("`wasm-bindgen` cannot be used with `no-std`");
#[cfg(all(feature = "no_std", feature = "stdweb"))]
#[cfg(feature = "no_std")]
#[cfg(feature = "stdweb")]
compile_error!("`stdweb` cannot be used with `no-std`");
#[cfg(all(target_family = "wasm", feature = "no_std"))]
#[cfg(target_family = "wasm")]
#[cfg(feature = "no_std")]
compile_error!("`no_std` cannot be used for WASM target");
#[cfg(all(not(target_family = "wasm"), feature = "wasm-bindgen"))]
#[cfg(not(target_family = "wasm"))]
#[cfg(feature = "wasm-bindgen")]
compile_error!("`wasm-bindgen` cannot be used for non-WASM target");
#[cfg(all(not(target_family = "wasm"), feature = "stdweb"))]
#[cfg(not(target_family = "wasm"))]
#[cfg(feature = "stdweb")]
compile_error!("`stdweb` cannot be used non-WASM target");
#[cfg(all(feature = "wasm-bindgen", feature = "stdweb"))]
#[cfg(feature = "wasm-bindgen")]
#[cfg(feature = "stdweb")]
compile_error!("`wasm-bindgen` and `stdweb` cannot be used together");

View File

@@ -155,7 +155,9 @@ mod time_functions {
})
}
} else {
Ok(timestamp - Duration::from_millis((seconds * 1000.0) as u64))
Ok(timestamp
.checked_sub(Duration::from_millis((seconds * 1000.0) as u64))
.unwrap())
}
}
@@ -212,7 +214,9 @@ mod time_functions {
))
})
} else {
Ok(timestamp - Duration::from_secs(seconds as u64))
Ok(timestamp
.checked_sub(Duration::from_secs(seconds as u64))
.unwrap())
}
}

View File

@@ -1203,7 +1203,7 @@ const fn is_hex_digit(c: char) -> bool {
/// Test if the given character is a numeric digit.
#[inline(always)]
const fn is_numeric_digit(c: char) -> bool {
matches!(c, '0'..='9')
c.is_ascii_digit()
}
/// Test if the comment block is a doc-comment.

View File

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