diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3d006be..7dabfb37 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,19 +88,6 @@ jobs: command: test args: ${{matrix.flags}} - feature_powerset: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: taiki-e/install-action@v2 - with: - tool: cargo-hack@0.5.25 - - run: cargo hack check --feature-powerset --depth 2 --no-dev-deps --exclude-features "stdweb wasm-bindgen f32_float" - # no-std builds are a bit more extensive to test no_std_build: name: NoStdBuild diff --git a/codegen/src/test/function.rs b/codegen/src/test/function.rs index 9db588e2..b45cc4bc 100644 --- a/codegen/src/test/function.rs +++ b/codegen/src/test/function.rs @@ -254,7 +254,7 @@ mod generate_tests { } (actual_diff, expected_diff) }; - eprintln!("actual != expected, diverge at char {}", counter); + eprintln!("actual != expected, diverge at char {counter}"); // eprintln!(" actual: {}", _actual_diff); // eprintln!("expected: {}", _expected_diff); // assert!(false); diff --git a/codegen/src/test/module.rs b/codegen/src/test/module.rs index 4ae05dfa..0f960956 100644 --- a/codegen/src/test/module.rs +++ b/codegen/src/test/module.rs @@ -301,7 +301,7 @@ mod generate_tests { } (actual_diff, expected_diff) }; - eprintln!("actual != expected, diverge at char {}", counter); + eprintln!("actual != expected, diverge at char {counter}"); // eprintln!(" actual: {}", _actual_diff); // eprintln!("expected: {}", _expected_diff); // assert!(false); diff --git a/codegen/tests/test_functions.rs b/codegen/tests/test_functions.rs index 8734f45b..3fdbf76a 100644 --- a/codegen/tests/test_functions.rs +++ b/codegen/tests/test_functions.rs @@ -62,7 +62,7 @@ mod raw_fn_str { #[export_fn] pub fn write_out_str(message: &str) -> bool { - eprintln!("{}", message); + eprintln!("{message}"); true } } diff --git a/codegen/tests/test_modules.rs b/codegen/tests/test_modules.rs index 7524e2b0..cbc61568 100644 --- a/codegen/tests/test_modules.rs +++ b/codegen/tests/test_modules.rs @@ -82,7 +82,7 @@ pub mod raw_fn_str_module { #[export_module] pub mod host_io { pub fn write_out_str(message: &str) -> bool { - eprintln!("{}", message); + eprintln!("{message}"); true } } diff --git a/examples/event_handler_main/main.rs b/examples/event_handler_main/main.rs index 43cfdb0e..2a1d8f79 100644 --- a/examples/event_handler_main/main.rs +++ b/examples/event_handler_main/main.rs @@ -44,7 +44,7 @@ pub fn main() { let mut input = String::new(); // Read script file - print!("Script file [{}]: ", SCRIPT_FILE); + print!("Script file [{SCRIPT_FILE}]: "); stdout().flush().expect("flush stdout"); input.clear(); diff --git a/src/api/eval.rs b/src/api/eval.rs index 8c90a757..7c00e01e 100644 --- a/src/api/eval.rs +++ b/src/api/eval.rs @@ -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()); diff --git a/src/ast/expr.rs b/src/ast/expr.rs index ffafc09a..c8cdedb1 100644 --- a/src/ast/expr.rs +++ b/src/ast/expr.rs @@ -287,7 +287,6 @@ pub enum Expr { Array(Box>, Position), /// #{ name:expr, ... } Map( - #[allow(clippy::type_complexity)] Box<(StaticVec<(Ident, Expr)>, BTreeMap)>, 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), diff --git a/src/lib.rs b/src/lib.rs index 70eb5c9b..9ac564bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -185,7 +185,8 @@ const INT_BYTES: usize = std::mem::size_of::(); /// 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::(); /// An exclusive integer range. @@ -213,7 +216,8 @@ type InclusiveRange = std::ops::RangeInclusive; 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; // 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"); diff --git a/src/packages/time_basic.rs b/src/packages/time_basic.rs index 828c8d8a..cf64bba1 100644 --- a/src/packages/time_basic.rs +++ b/src/packages/time_basic.rs @@ -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()) } } diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 16381ccf..f6a0a72e 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -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. diff --git a/src/types/fn_ptr.rs b/src/types/fn_ptr.rs index 192fe674..155eaa27 100644 --- a/src/types/fn_ptr.rs +++ b/src/types/fn_ptr.rs @@ -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, ) -> (