Skip to content

Commit

Permalink
Fix new lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
ISibboI committed Oct 11, 2024
1 parent a90a7bf commit 6608b16
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'] }
4 changes: 2 additions & 2 deletions benches/benchs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const EXPONENTIAL_TUPLE_ITERATIONS: usize = 12;

fn generate_expression<Gen: Rng>(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();

Expand Down
1 change: 1 addition & 0 deletions src/context/predefined/mod.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/feature_serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/function/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn builtin_function(identifier: &str) -> Option<Function> {
})),
"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());

Expand All @@ -132,7 +132,7 @@ pub fn builtin_function(identifier: &str) -> Option<Function> {
})),
"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());

Expand Down
2 changes: 2 additions & 0 deletions src/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
34 changes: 7 additions & 27 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 6608b16

Please sign in to comment.