aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock83
-rw-r--r--bin/Cargo.toml9
-rw-r--r--bin/src/lint.rs9
-rw-r--r--flake.lock18
-rw-r--r--flake.nix4
-rw-r--r--lib/src/lib.rs2
-rw-r--r--vfs/Cargo.toml2
-rw-r--r--vfs/src/lib.rs8
8 files changed, 117 insertions, 18 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b4e82be..e23afee 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -124,6 +124,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
124checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" 124checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58"
125 125
126[[package]] 126[[package]]
127name = "crossbeam-channel"
128version = "0.5.2"
129source = "registry+https://github.com/rust-lang/crates.io-index"
130checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"
131dependencies = [
132 "cfg-if",
133 "crossbeam-utils",
134]
135
136[[package]]
137name = "crossbeam-deque"
138version = "0.8.1"
139source = "registry+https://github.com/rust-lang/crates.io-index"
140checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
141dependencies = [
142 "cfg-if",
143 "crossbeam-epoch",
144 "crossbeam-utils",
145]
146
147[[package]]
148name = "crossbeam-epoch"
149version = "0.9.7"
150source = "registry+https://github.com/rust-lang/crates.io-index"
151checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
152dependencies = [
153 "cfg-if",
154 "crossbeam-utils",
155 "lazy_static",
156 "memoffset",
157 "scopeguard",
158]
159
160[[package]]
127name = "crossbeam-utils" 161name = "crossbeam-utils"
128version = "0.8.5" 162version = "0.8.5"
129source = "registry+https://github.com/rust-lang/crates.io-index" 163source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -140,6 +174,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
140checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" 174checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
141 175
142[[package]] 176[[package]]
177name = "either"
178version = "1.6.1"
179source = "registry+https://github.com/rust-lang/crates.io-index"
180checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
181
182[[package]]
143name = "encode_unicode" 183name = "encode_unicode"
144version = "0.3.6" 184version = "0.3.6"
145source = "registry+https://github.com/rust-lang/crates.io-index" 185source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -323,6 +363,16 @@ dependencies = [
323] 363]
324 364
325[[package]] 365[[package]]
366name = "num_cpus"
367version = "1.13.1"
368source = "registry+https://github.com/rust-lang/crates.io-index"
369checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
370dependencies = [
371 "hermit-abi",
372 "libc",
373]
374
375[[package]]
326name = "once_cell" 376name = "once_cell"
327version = "1.8.0" 377version = "1.8.0"
328source = "registry+https://github.com/rust-lang/crates.io-index" 378source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -380,6 +430,31 @@ dependencies = [
380] 430]
381 431
382[[package]] 432[[package]]
433name = "rayon"
434version = "1.5.1"
435source = "registry+https://github.com/rust-lang/crates.io-index"
436checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90"
437dependencies = [
438 "autocfg",
439 "crossbeam-deque",
440 "either",
441 "rayon-core",
442]
443
444[[package]]
445name = "rayon-core"
446version = "1.9.1"
447source = "registry+https://github.com/rust-lang/crates.io-index"
448checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
449dependencies = [
450 "crossbeam-channel",
451 "crossbeam-deque",
452 "crossbeam-utils",
453 "lazy_static",
454 "num_cpus",
455]
456
457[[package]]
383name = "regex" 458name = "regex"
384version = "1.5.4" 459version = "1.5.4"
385source = "registry+https://github.com/rust-lang/crates.io-index" 460source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -442,6 +517,12 @@ dependencies = [
442] 517]
443 518
444[[package]] 519[[package]]
520name = "scopeguard"
521version = "1.1.0"
522source = "registry+https://github.com/rust-lang/crates.io-index"
523checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
524
525[[package]]
445name = "serde" 526name = "serde"
446version = "1.0.130" 527version = "1.0.130"
447source = "registry+https://github.com/rust-lang/crates.io-index" 528source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -514,6 +595,7 @@ dependencies = [
514 "ignore", 595 "ignore",
515 "insta", 596 "insta",
516 "lib", 597 "lib",
598 "rayon",
517 "rnix", 599 "rnix",
518 "serde", 600 "serde",
519 "serde_json", 601 "serde_json",
@@ -672,6 +754,7 @@ name = "vfs"
672version = "0.0.0" 754version = "0.0.0"
673dependencies = [ 755dependencies = [
674 "indexmap", 756 "indexmap",
757 "rayon",
675] 758]
676 759
677[[package]] 760[[package]]
diff --git a/bin/Cargo.toml b/bin/Cargo.toml
index bf39a3a..715e466 100644
--- a/bin/Cargo.toml
+++ b/bin/Cargo.toml
@@ -16,14 +16,15 @@ path = "src/main.rs"
16 16
17[dependencies] 17[dependencies]
18ariadne = "0.1.3" 18ariadne = "0.1.3"
19rnix = "0.10.1"
20clap = "3.0.0-beta.4" 19clap = "3.0.0-beta.4"
21ignore = "0.4.18" 20ignore = "0.4.18"
22thiserror = "1.0.30"
23similar = "2.1.0"
24vfs = { path = "../vfs" }
25lib = { path = "../lib" } 21lib = { path = "../lib" }
22rayon = "1.5.1"
23rnix = "0.10.1"
24similar = "2.1.0"
25thiserror = "1.0.30"
26toml = "0.5.8" 26toml = "0.5.8"
27vfs = { path = "../vfs" }
27 28
28[dependencies.serde] 29[dependencies.serde]
29version = "1.0.68" 30version = "1.0.68"
diff --git a/bin/src/lint.rs b/bin/src/lint.rs
index 23a1d10..e1544e1 100644
--- a/bin/src/lint.rs
+++ b/bin/src/lint.rs
@@ -50,6 +50,7 @@ pub mod main {
50 }; 50 };
51 51
52 use lib::session::SessionInfo; 52 use lib::session::SessionInfo;
53 use rayon::prelude::*;
53 54
54 pub fn main(check_config: CheckConfig) -> Result<(), StatixErr> { 55 pub fn main(check_config: CheckConfig) -> Result<(), StatixErr> {
55 let vfs = check_config.vfs()?; 56 let vfs = check_config.vfs()?;
@@ -59,9 +60,13 @@ pub mod main {
59 let version = conf_file.version()?; 60 let version = conf_file.version()?;
60 let session = SessionInfo::from_version(version); 61 let session = SessionInfo::from_version(version);
61 let lint = |vfs_entry| lint_with(vfs_entry, &lints, &session); 62 let lint = |vfs_entry| lint_with(vfs_entry, &lints, &session);
62 let results = vfs.iter().map(lint).collect::<Vec<_>>(); 63 let results = vfs
64 .par_iter()
65 .map(lint)
66 .filter(|lr| !lr.reports.is_empty())
67 .collect::<Vec<_>>();
63 68
64 if results.iter().map(|r| r.reports.len()).sum::<usize>() != 0 { 69 if results.len() != 0 {
65 for r in &results { 70 for r in &results {
66 stdout.write(&r, &vfs, check_config.format).unwrap(); 71 stdout.write(&r, &vfs, check_config.format).unwrap();
67 } 72 }
diff --git a/flake.lock b/flake.lock
index 1e575e3..a7c083f 100644
--- a/flake.lock
+++ b/flake.lock
@@ -8,11 +8,11 @@
8 "rust-analyzer-src": "rust-analyzer-src" 8 "rust-analyzer-src": "rust-analyzer-src"
9 }, 9 },
10 "locked": { 10 "locked": {
11 "lastModified": 1642141613, 11 "lastModified": 1645251813,
12 "narHash": "sha256-WFS7T5oOLD8anu/77iz7EPz7zQsJZtP5qVa5485k3dI=", 12 "narHash": "sha256-cQ66tGjnZclBCS3nD26mZ5fUH+3/HnysGffBiWXUSHk=",
13 "owner": "nix-community", 13 "owner": "nix-community",
14 "repo": "fenix", 14 "repo": "fenix",
15 "rev": "d75ffc9f1d3b60bb597e48ae01f486a6de27d30e", 15 "rev": "9892337b588c38ec59466a1c89befce464aae7f8",
16 "type": "github" 16 "type": "github"
17 }, 17 },
18 "original": { 18 "original": {
@@ -43,11 +43,11 @@
43 }, 43 },
44 "nixpkgs": { 44 "nixpkgs": {
45 "locked": { 45 "locked": {
46 "lastModified": 1642069818, 46 "lastModified": 1645013224,
47 "narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=", 47 "narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=",
48 "owner": "nixos", 48 "owner": "nixos",
49 "repo": "nixpkgs", 49 "repo": "nixpkgs",
50 "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", 50 "rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970",
51 "type": "github" 51 "type": "github"
52 }, 52 },
53 "original": { 53 "original": {
@@ -67,11 +67,11 @@
67 "rust-analyzer-src": { 67 "rust-analyzer-src": {
68 "flake": false, 68 "flake": false,
69 "locked": { 69 "locked": {
70 "lastModified": 1642101527, 70 "lastModified": 1645205556,
71 "narHash": "sha256-C4zcaWULWlrirpEt/pA85CCMBt+7SWZweMaMJ7EvrXw=", 71 "narHash": "sha256-e4lZW3qRyOEJ+vLKFQP7m2Dxh5P44NrnekZYLxlucww=",
72 "owner": "rust-analyzer", 72 "owner": "rust-analyzer",
73 "repo": "rust-analyzer", 73 "repo": "rust-analyzer",
74 "rev": "b4c31481a554d0132003228ba319bd9476fe85ae", 74 "rev": "acf5874b39f3dc5262317a6074d9fc7285081161",
75 "type": "github" 75 "type": "github"
76 }, 76 },
77 "original": { 77 "original": {
diff --git a/flake.nix b/flake.nix
index 9bb9332..f6099e0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -33,9 +33,9 @@
33 }); 33 });
34 34
35 chanspec = { 35 chanspec = {
36 date = "2021-12-01"; 36 date = "2022-02-06";
37 channel = "nightly"; 37 channel = "nightly";
38 sha256 = "DhIP1w63/hMbWlgElJGBumEK/ExFWCdLaeBV5F8uWHc="; # set zeros after modifying channel or date 38 sha256 = "oKkTWopCDx4tphzTtRn+zDDtvmIZrL/H44tV2ruSfDw="; # set zeros after modifying channel or date
39 }; 39 };
40 rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec; 40 rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec;
41 41
diff --git a/lib/src/lib.rs b/lib/src/lib.rs
index cc4818a..8c05706 100644
--- a/lib/src/lib.rs
+++ b/lib/src/lib.rs
@@ -201,6 +201,8 @@ impl Suggestion {
201 } 201 }
202} 202}
203 203
204unsafe impl Send for Suggestion {}
205
204#[cfg(feature = "json-out")] 206#[cfg(feature = "json-out")]
205impl Serialize for Suggestion { 207impl Serialize for Suggestion {
206 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 208 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
diff --git a/vfs/Cargo.toml b/vfs/Cargo.toml
index 7a5dc6b..d1d654c 100644
--- a/vfs/Cargo.toml
+++ b/vfs/Cargo.toml
@@ -6,4 +6,4 @@ license = "MIT"
6 6
7[dependencies] 7[dependencies]
8indexmap = "1.6.2" 8indexmap = "1.6.2"
9 9rayon = "1.5.1"
diff --git a/vfs/src/lib.rs b/vfs/src/lib.rs
index cd6cc03..2d7577d 100644
--- a/vfs/src/lib.rs
+++ b/vfs/src/lib.rs
@@ -5,6 +5,7 @@ use std::{
5}; 5};
6 6
7use indexmap::IndexSet; 7use indexmap::IndexSet;
8use rayon::prelude::*;
8 9
9#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] 10#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
10pub struct FileId(pub u32); 11pub struct FileId(pub u32);
@@ -70,6 +71,13 @@ impl ReadOnlyVfs {
70 contents: self.get_str(*file_id), 71 contents: self.get_str(*file_id),
71 }) 72 })
72 } 73 }
74 pub fn par_iter(&self) -> impl ParallelIterator<Item = VfsEntry> {
75 self.data.par_iter().map(move |(file_id, _)| VfsEntry {
76 file_id: *file_id,
77 file_path: self.file_path(*file_id),
78 contents: self.get_str(*file_id),
79 })
80 }
73} 81}
74 82
75pub struct VfsEntry<'ρ> { 83pub struct VfsEntry<'ρ> {