pull main & udpate lint

This commit is contained in:
Mathieu Lala 2023-02-05 17:59:02 +01:00
parent 097fa1f4e3
commit 9bdf3c290d
No known key found for this signature in database
GPG Key ID: C5D308ABEB84866F
12 changed files with 44 additions and 41 deletions

View File

@ -88,19 +88,6 @@ jobs:
command: test command: test
args: ${{matrix.flags}} 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 builds are a bit more extensive to test
no_std_build: no_std_build:
name: NoStdBuild name: NoStdBuild

View File

@ -254,7 +254,7 @@ mod generate_tests {
} }
(actual_diff, expected_diff) (actual_diff, expected_diff)
}; };
eprintln!("actual != expected, diverge at char {}", counter); eprintln!("actual != expected, diverge at char {counter}");
// eprintln!(" actual: {}", _actual_diff); // eprintln!(" actual: {}", _actual_diff);
// eprintln!("expected: {}", _expected_diff); // eprintln!("expected: {}", _expected_diff);
// assert!(false); // assert!(false);

View File

@ -301,7 +301,7 @@ mod generate_tests {
} }
(actual_diff, expected_diff) (actual_diff, expected_diff)
}; };
eprintln!("actual != expected, diverge at char {}", counter); eprintln!("actual != expected, diverge at char {counter}");
// eprintln!(" actual: {}", _actual_diff); // eprintln!(" actual: {}", _actual_diff);
// eprintln!("expected: {}", _expected_diff); // eprintln!("expected: {}", _expected_diff);
// assert!(false); // assert!(false);

View File

@ -62,7 +62,7 @@ mod raw_fn_str {
#[export_fn] #[export_fn]
pub fn write_out_str(message: &str) -> bool { pub fn write_out_str(message: &str) -> bool {
eprintln!("{}", message); eprintln!("{message}");
true true
} }
} }

View File

@ -82,7 +82,7 @@ pub mod raw_fn_str_module {
#[export_module] #[export_module]
pub mod host_io { pub mod host_io {
pub fn write_out_str(message: &str) -> bool { pub fn write_out_str(message: &str) -> bool {
eprintln!("{}", message); eprintln!("{message}");
true true
} }
} }

View File

@ -44,7 +44,7 @@ pub fn main() {
let mut input = String::new(); let mut input = String::new();
// Read script file // Read script file
print!("Script file [{}]: ", SCRIPT_FILE); print!("Script file [{SCRIPT_FILE}]: ");
stdout().flush().expect("flush stdout"); stdout().flush().expect("flush stdout");
input.clear(); input.clear();

View File

@ -212,12 +212,12 @@ impl Engine {
} }
/// Evaluate an [`AST`] with own scope, returning the result value or an error. /// Evaluate an [`AST`] with own scope, returning the result value or an error.
#[inline] #[inline]
pub(crate) fn eval_ast_with_scope_raw<'a>( pub(crate) fn eval_ast_with_scope_raw(
&self, &self,
global: &mut GlobalRuntimeState, global: &mut GlobalRuntimeState,
caches: &mut Caches, caches: &mut Caches,
scope: &mut Scope, scope: &mut Scope,
ast: &'a AST, ast: &AST,
) -> RhaiResult { ) -> RhaiResult {
let orig_source = mem::replace(&mut global.source, ast.source_raw().cloned()); 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), Array(Box<StaticVec<Expr>>, Position),
/// #{ name:expr, ... } /// #{ name:expr, ... }
Map( Map(
#[allow(clippy::type_complexity)]
Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>, Box<(StaticVec<(Ident, Expr)>, BTreeMap<Identifier, Dynamic>)>,
Position, Position,
), ),
@ -305,7 +304,6 @@ pub enum Expr {
), ),
/// Property access - ((getter, hash), (setter, hash), prop) /// Property access - ((getter, hash), (setter, hash), prop)
Property( Property(
#[allow(clippy::type_complexity)]
Box<( Box<(
(ImmutableString, u64), (ImmutableString, u64),
(ImmutableString, u64), (ImmutableString, u64),

View File

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

View File

@ -155,7 +155,9 @@ mod time_functions {
}) })
} }
} else { } 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 { } 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. /// Test if the given character is a numeric digit.
#[inline(always)] #[inline(always)]
const fn is_numeric_digit(c: char) -> bool { 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. /// Test if the comment block is a doc-comment.

View File

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