diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b4bc6c..be8efc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,6 +117,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: nightly + components: clippy - name: cargo check run: cargo check --all-features --benches @@ -154,6 +155,8 @@ jobs: - name: Install toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable - name: Install cargo-sync-readme run: cargo install cargo-sync-readme diff --git a/Cargo.toml b/Cargo.toml index 4fba2c1..ba48e8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,3 +36,6 @@ regex_support = ["regex"] ron = "0.7.0" rand = "0.8.5" rand_pcg = "0.3.1" + +[lints.rust] + unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] } \ No newline at end of file diff --git a/benches/benchs.rs b/benches/benchs.rs index cab2ee0..132a12b 100644 --- a/benches/benchs.rs +++ b/benches/benchs.rs @@ -16,8 +16,8 @@ const EXPONENTIAL_TUPLE_ITERATIONS: usize = 12; fn generate_expression(len: usize, gen: &mut Gen) -> String { let int_distribution = Uniform::new_inclusive(1, 100); - let whitespaces = vec![" ", "", "", " ", " \n", " "]; - let operators = vec!["+", "-", "*", "/", "%", "^"]; + let whitespaces = [" ", "", "", " ", " \n", " "]; + let operators = ["+", "-", "*", "/", "%", "^"]; let mut result = String::new(); write!(result, "{}", gen.sample(int_distribution)).unwrap(); diff --git a/src/context/predefined/mod.rs b/src/context/predefined/mod.rs index 1b1f4b6..ad8e785 100644 --- a/src/context/predefined/mod.rs +++ b/src/context/predefined/mod.rs @@ -1,4 +1,5 @@ /// Context with all Rust's constants in `f64::consts` available by default. +/// /// Alternatively, specifiy constants with `math_consts_context!(E, PI, TAU, ...)` /// Available constants can be found in the [`core::f64::consts module`](https://doc.rust-lang.org/nightly/core/f64/consts/index.html). #[macro_export] diff --git a/src/feature_serde/mod.rs b/src/feature_serde/mod.rs index 9cb2789..ee2f85f 100644 --- a/src/feature_serde/mod.rs +++ b/src/feature_serde/mod.rs @@ -13,7 +13,7 @@ impl<'de> Deserialize<'de> for Node { struct NodeVisitor; -impl<'de> de::Visitor<'de> for NodeVisitor { +impl de::Visitor<'_> for NodeVisitor { type Value = Node; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/function/builtin.rs b/src/function/builtin.rs index be55e93..da543bc 100644 --- a/src/function/builtin.rs +++ b/src/function/builtin.rs @@ -110,7 +110,7 @@ pub fn builtin_function(identifier: &str) -> Option { })), "min" => Some(Function::new(|argument| { let arguments = argument.as_tuple()?; - let mut min_int = IntType::max_value(); + let mut min_int = IntType::MAX; let mut min_float: FloatType = 1.0 / 0.0; debug_assert!(min_float.is_infinite()); @@ -132,7 +132,7 @@ pub fn builtin_function(identifier: &str) -> Option { })), "max" => Some(Function::new(|argument| { let arguments = argument.as_tuple()?; - let mut max_int = IntType::min_value(); + let mut max_int = IntType::MIN; let mut max_float: FloatType = -1.0 / 0.0; debug_assert!(max_float.is_infinite()); diff --git a/src/function/mod.rs b/src/function/mod.rs index 75d5a4c..c590107 100644 --- a/src/function/mod.rs +++ b/src/function/mod.rs @@ -78,6 +78,8 @@ impl fmt::Debug for Function { /// A trait to ensure a type is `Send` and `Sync`. /// If implemented for a type, the crate will not compile if the type is not `Send` and `Sync`. +#[allow(dead_code)] +#[doc(hidden)] trait IsSendAndSync: Send + Sync {} impl IsSendAndSync for Function {} diff --git a/tests/integration.rs b/tests/integration.rs index 695056b..f63acec 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -583,33 +583,13 @@ fn test_errors() { #[test] fn test_no_panic() { - assert!(eval(&format!( - "{} + {}", - IntType::max_value(), - IntType::max_value() - )) - .is_err()); - assert!(eval(&format!( - "-{} - {}", - IntType::max_value(), - IntType::max_value() - )) - .is_err()); - assert!(eval(&format!("-(-{} - 1)", IntType::max_value())).is_err()); - assert!(eval(&format!( - "{} * {}", - IntType::max_value(), - IntType::max_value() - )) - .is_err()); - assert!(eval(&format!("{} / {}", IntType::max_value(), 0)).is_err()); - assert!(eval(&format!("{} % {}", IntType::max_value(), 0)).is_err()); - assert!(eval(&format!( - "{} ^ {}", - IntType::max_value(), - IntType::max_value() - )) - .is_ok()); + assert!(eval(&format!("{} + {}", IntType::MAX, IntType::MAX)).is_err()); + assert!(eval(&format!("-{} - {}", IntType::MAX, IntType::MAX)).is_err()); + assert!(eval(&format!("-(-{} - 1)", IntType::MAX)).is_err()); + assert!(eval(&format!("{} * {}", IntType::MAX, IntType::MAX)).is_err()); + assert!(eval(&format!("{} / {}", IntType::MAX, 0)).is_err()); + assert!(eval(&format!("{} % {}", IntType::MAX, 0)).is_err()); + assert!(eval(&format!("{} ^ {}", IntType::MAX, IntType::MAX)).is_ok()); assert!(eval("if").is_err()); assert!(eval("if()").is_err()); assert!(eval("if(true, 1)").is_err());