pull main & udpate lint
This commit is contained in:
parent
097fa1f4e3
commit
9bdf3c290d
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -62,7 +62,7 @@ mod raw_fn_str {
|
||||
|
||||
#[export_fn]
|
||||
pub fn write_out_str(message: &str) -> bool {
|
||||
eprintln!("{}", message);
|
||||
eprintln!("{message}");
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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),
|
||||
|
45
src/lib.rs
45
src/lib.rs
@ -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");
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
) -> (
|
||||
|
Loading…
Reference in New Issue
Block a user