Skip to content

Commit 6608b16

Browse files
committed
Fix new lints.
1 parent a90a7bf commit 6608b16

File tree

8 files changed

+21
-32
lines changed

8 files changed

+21
-32
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ jobs:
117117
uses: actions-rust-lang/setup-rust-toolchain@v1
118118
with:
119119
toolchain: nightly
120+
components: clippy
120121

121122
- name: cargo check
122123
run: cargo check --all-features --benches
@@ -154,6 +155,8 @@ jobs:
154155

155156
- name: Install toolchain
156157
uses: actions-rust-lang/setup-rust-toolchain@v1
158+
with:
159+
toolchain: stable
157160

158161
- name: Install cargo-sync-readme
159162
run: cargo install cargo-sync-readme

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ regex_support = ["regex"]
3636
ron = "0.7.0"
3737
rand = "0.8.5"
3838
rand_pcg = "0.3.1"
39+
40+
[lints.rust]
41+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

benches/benchs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const EXPONENTIAL_TUPLE_ITERATIONS: usize = 12;
1616

1717
fn generate_expression<Gen: Rng>(len: usize, gen: &mut Gen) -> String {
1818
let int_distribution = Uniform::new_inclusive(1, 100);
19-
let whitespaces = vec![" ", "", "", " ", " \n", " "];
20-
let operators = vec!["+", "-", "*", "/", "%", "^"];
19+
let whitespaces = [" ", "", "", " ", " \n", " "];
20+
let operators = ["+", "-", "*", "/", "%", "^"];
2121
let mut result = String::new();
2222
write!(result, "{}", gen.sample(int_distribution)).unwrap();
2323

src/context/predefined/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// Context with all Rust's constants in `f64::consts` available by default.
2+
///
23
/// Alternatively, specifiy constants with `math_consts_context!(E, PI, TAU, ...)`
34
/// Available constants can be found in the [`core::f64::consts module`](https://doc.rust-lang.org/nightly/core/f64/consts/index.html).
45
#[macro_export]

src/feature_serde/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl<'de> Deserialize<'de> for Node {
1313

1414
struct NodeVisitor;
1515

16-
impl<'de> de::Visitor<'de> for NodeVisitor {
16+
impl de::Visitor<'_> for NodeVisitor {
1717
type Value = Node;
1818

1919
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {

src/function/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub fn builtin_function(identifier: &str) -> Option<Function> {
110110
})),
111111
"min" => Some(Function::new(|argument| {
112112
let arguments = argument.as_tuple()?;
113-
let mut min_int = IntType::max_value();
113+
let mut min_int = IntType::MAX;
114114
let mut min_float: FloatType = 1.0 / 0.0;
115115
debug_assert!(min_float.is_infinite());
116116

@@ -132,7 +132,7 @@ pub fn builtin_function(identifier: &str) -> Option<Function> {
132132
})),
133133
"max" => Some(Function::new(|argument| {
134134
let arguments = argument.as_tuple()?;
135-
let mut max_int = IntType::min_value();
135+
let mut max_int = IntType::MIN;
136136
let mut max_float: FloatType = -1.0 / 0.0;
137137
debug_assert!(max_float.is_infinite());
138138

src/function/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ impl fmt::Debug for Function {
7878

7979
/// A trait to ensure a type is `Send` and `Sync`.
8080
/// If implemented for a type, the crate will not compile if the type is not `Send` and `Sync`.
81+
#[allow(dead_code)]
82+
#[doc(hidden)]
8183
trait IsSendAndSync: Send + Sync {}
8284

8385
impl IsSendAndSync for Function {}

tests/integration.rs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -583,33 +583,13 @@ fn test_errors() {
583583

584584
#[test]
585585
fn test_no_panic() {
586-
assert!(eval(&format!(
587-
"{} + {}",
588-
IntType::max_value(),
589-
IntType::max_value()
590-
))
591-
.is_err());
592-
assert!(eval(&format!(
593-
"-{} - {}",
594-
IntType::max_value(),
595-
IntType::max_value()
596-
))
597-
.is_err());
598-
assert!(eval(&format!("-(-{} - 1)", IntType::max_value())).is_err());
599-
assert!(eval(&format!(
600-
"{} * {}",
601-
IntType::max_value(),
602-
IntType::max_value()
603-
))
604-
.is_err());
605-
assert!(eval(&format!("{} / {}", IntType::max_value(), 0)).is_err());
606-
assert!(eval(&format!("{} % {}", IntType::max_value(), 0)).is_err());
607-
assert!(eval(&format!(
608-
"{} ^ {}",
609-
IntType::max_value(),
610-
IntType::max_value()
611-
))
612-
.is_ok());
586+
assert!(eval(&format!("{} + {}", IntType::MAX, IntType::MAX)).is_err());
587+
assert!(eval(&format!("-{} - {}", IntType::MAX, IntType::MAX)).is_err());
588+
assert!(eval(&format!("-(-{} - 1)", IntType::MAX)).is_err());
589+
assert!(eval(&format!("{} * {}", IntType::MAX, IntType::MAX)).is_err());
590+
assert!(eval(&format!("{} / {}", IntType::MAX, 0)).is_err());
591+
assert!(eval(&format!("{} % {}", IntType::MAX, 0)).is_err());
592+
assert!(eval(&format!("{} ^ {}", IntType::MAX, IntType::MAX)).is_ok());
613593
assert!(eval("if").is_err());
614594
assert!(eval("if()").is_err());
615595
assert!(eval("if(true, 1)").is_err());

0 commit comments

Comments
 (0)