diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Cargo.toml | 5 | ||||
-rw-r--r-- | lib/src/lints/bool_comparison.rs | 5 | ||||
-rw-r--r-- | lib/src/lints/empty_pattern.rs | 1 |
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 54b9c52..d90c5bf 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml | |||
@@ -7,13 +7,16 @@ license = "MIT" | |||
7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
8 | 8 | ||
9 | [dependencies] | 9 | [dependencies] |
10 | rnix = "0.9.0" | ||
11 | if_chain = "1.0" | 10 | if_chain = "1.0" |
12 | macros = { path = "../macros" } | 11 | macros = { path = "../macros" } |
13 | lazy_static = "1.0" | 12 | lazy_static = "1.0" |
14 | rowan = "0.12.5" | 13 | rowan = "0.12.5" |
15 | serde_json = { version = "1.0.68", optional = true } | 14 | serde_json = { version = "1.0.68", optional = true } |
16 | 15 | ||
16 | [dependencies.rnix] | ||
17 | git = "https://github.com/nix-community/rnix-parser" | ||
18 | rev = "8083f5694ddeaca47c946aa9ae7ecf117fa4823b" | ||
19 | |||
17 | [dependencies.serde] | 20 | [dependencies.serde] |
18 | version = "1.0.130" | 21 | version = "1.0.130" |
19 | features = [ "derive" ] | 22 | features = [ "derive" ] |
diff --git a/lib/src/lints/bool_comparison.rs b/lib/src/lints/bool_comparison.rs index ef7f5d2..5402f31 100644 --- a/lib/src/lints/bool_comparison.rs +++ b/lib/src/lints/bool_comparison.rs | |||
@@ -41,8 +41,9 @@ impl Rule for BoolComparison { | |||
41 | if let Some(bin_expr) = BinOp::cast(node.clone()); | 41 | if let Some(bin_expr) = BinOp::cast(node.clone()); |
42 | if let Some(lhs) = bin_expr.lhs(); | 42 | if let Some(lhs) = bin_expr.lhs(); |
43 | if let Some(rhs) = bin_expr.rhs(); | 43 | if let Some(rhs) = bin_expr.rhs(); |
44 | if let Some(op) = bin_expr.operator(); | ||
44 | 45 | ||
45 | if let op@(BinOpKind::Equal | BinOpKind::NotEqual) = bin_expr.operator(); | 46 | if let BinOpKind::Equal | BinOpKind::NotEqual = op; |
46 | let (non_bool_side, bool_side) = if boolean_ident(&lhs).is_some() { | 47 | let (non_bool_side, bool_side) = if boolean_ident(&lhs).is_some() { |
47 | (rhs, lhs) | 48 | (rhs, lhs) |
48 | } else if boolean_ident(&rhs).is_some() { | 49 | } else if boolean_ident(&rhs).is_some() { |
@@ -70,7 +71,7 @@ impl Rule for BoolComparison { | |||
70 | SyntaxKind::NODE_BIN_OP => { | 71 | SyntaxKind::NODE_BIN_OP => { |
71 | let inner = BinOp::cast(non_bool_side.clone()).unwrap(); | 72 | let inner = BinOp::cast(non_bool_side.clone()).unwrap(); |
72 | // `!a ? b`, no paren required | 73 | // `!a ? b`, no paren required |
73 | if inner.operator() == BinOpKind::IsSet { | 74 | if inner.operator()? == BinOpKind::IsSet { |
74 | make::unary_not(&non_bool_side).node().clone() | 75 | make::unary_not(&non_bool_side).node().clone() |
75 | } else { | 76 | } else { |
76 | let parens = make::parenthesize(&non_bool_side); | 77 | let parens = make::parenthesize(&non_bool_side); |
diff --git a/lib/src/lints/empty_pattern.rs b/lib/src/lints/empty_pattern.rs index b399ba2..14c3b5e 100644 --- a/lib/src/lints/empty_pattern.rs +++ b/lib/src/lints/empty_pattern.rs | |||
@@ -49,6 +49,7 @@ impl Rule for EmptyPattern { | |||
49 | if let Some(body) = lambda_expr.body(); | 49 | if let Some(body) = lambda_expr.body(); |
50 | 50 | ||
51 | if let Some(pattern) = Pattern::cast(arg.clone()); | 51 | if let Some(pattern) = Pattern::cast(arg.clone()); |
52 | |||
52 | // no patterns within `{ }` | 53 | // no patterns within `{ }` |
53 | if pattern.entries().count() == 0; | 54 | if pattern.entries().count() == 0; |
54 | // pattern is not bound | 55 | // pattern is not bound |