From df29effd59bb8971395419b79e8c0e51f373d4fb Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 29 Jan 2022 16:31:20 +0530 Subject: bump rnix to latest master, support nix 2.5 syntax --- Cargo.lock | 5 ++--- bin/Cargo.toml | 5 ++++- lib/Cargo.toml | 5 ++++- lib/src/lints/bool_comparison.rs | 5 +++-- lib/src/lints/empty_pattern.rs | 1 + 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a542e65..5b347d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -398,9 +398,8 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rnix" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "294becb48f58c496d96c10a12df290266204ca75c9799be4d04222bfaebb6a37" +version = "0.10.1" +source = "git+https://github.com/nix-community/rnix-parser?rev=8083f5694ddeaca47c946aa9ae7ecf117fa4823b#8083f5694ddeaca47c946aa9ae7ecf117fa4823b" dependencies = [ "cbitset", "rowan", diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 4e83ee3..34d6513 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -16,7 +16,6 @@ path = "src/main.rs" [dependencies] ariadne = "0.1.3" -rnix = "0.9.0" clap = "3.0.0-beta.4" ignore = "0.4.18" thiserror = "1.0.30" @@ -25,6 +24,10 @@ vfs = { path = "../vfs" } lib = { path = "../lib" } toml = "0.5.8" +[dependencies.rnix] +git = "https://github.com/nix-community/rnix-parser" +rev = "8083f5694ddeaca47c946aa9ae7ecf117fa4823b" + [dependencies.serde] version = "1.0.68" features = [ "derive" ] 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" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rnix = "0.9.0" if_chain = "1.0" macros = { path = "../macros" } lazy_static = "1.0" rowan = "0.12.5" serde_json = { version = "1.0.68", optional = true } +[dependencies.rnix] +git = "https://github.com/nix-community/rnix-parser" +rev = "8083f5694ddeaca47c946aa9ae7ecf117fa4823b" + [dependencies.serde] version = "1.0.130" 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 { if let Some(bin_expr) = BinOp::cast(node.clone()); if let Some(lhs) = bin_expr.lhs(); if let Some(rhs) = bin_expr.rhs(); + if let Some(op) = bin_expr.operator(); - if let op@(BinOpKind::Equal | BinOpKind::NotEqual) = bin_expr.operator(); + if let BinOpKind::Equal | BinOpKind::NotEqual = op; let (non_bool_side, bool_side) = if boolean_ident(&lhs).is_some() { (rhs, lhs) } else if boolean_ident(&rhs).is_some() { @@ -70,7 +71,7 @@ impl Rule for BoolComparison { SyntaxKind::NODE_BIN_OP => { let inner = BinOp::cast(non_bool_side.clone()).unwrap(); // `!a ? b`, no paren required - if inner.operator() == BinOpKind::IsSet { + if inner.operator()? == BinOpKind::IsSet { make::unary_not(&non_bool_side).node().clone() } else { 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 { if let Some(body) = lambda_expr.body(); if let Some(pattern) = Pattern::cast(arg.clone()); + // no patterns within `{ }` if pattern.entries().count() == 0; // pattern is not bound -- cgit v1.2.3