diff options
-rw-r--r-- | Cargo.lock | 83 | ||||
-rw-r--r-- | bin/Cargo.toml | 9 | ||||
-rw-r--r-- | bin/src/lint.rs | 9 | ||||
-rw-r--r-- | flake.lock | 18 | ||||
-rw-r--r-- | flake.nix | 4 | ||||
-rw-r--r-- | lib/src/lib.rs | 2 | ||||
-rw-r--r-- | vfs/Cargo.toml | 2 | ||||
-rw-r--r-- | vfs/src/lib.rs | 8 |
8 files changed, 117 insertions, 18 deletions
@@ -124,6 +124,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
124 | checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" | 124 | checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" |
125 | 125 | ||
126 | [[package]] | 126 | [[package]] |
127 | name = "crossbeam-channel" | ||
128 | version = "0.5.2" | ||
129 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
130 | checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" | ||
131 | dependencies = [ | ||
132 | "cfg-if", | ||
133 | "crossbeam-utils", | ||
134 | ] | ||
135 | |||
136 | [[package]] | ||
137 | name = "crossbeam-deque" | ||
138 | version = "0.8.1" | ||
139 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
140 | checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" | ||
141 | dependencies = [ | ||
142 | "cfg-if", | ||
143 | "crossbeam-epoch", | ||
144 | "crossbeam-utils", | ||
145 | ] | ||
146 | |||
147 | [[package]] | ||
148 | name = "crossbeam-epoch" | ||
149 | version = "0.9.7" | ||
150 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
151 | checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" | ||
152 | dependencies = [ | ||
153 | "cfg-if", | ||
154 | "crossbeam-utils", | ||
155 | "lazy_static", | ||
156 | "memoffset", | ||
157 | "scopeguard", | ||
158 | ] | ||
159 | |||
160 | [[package]] | ||
127 | name = "crossbeam-utils" | 161 | name = "crossbeam-utils" |
128 | version = "0.8.5" | 162 | version = "0.8.5" |
129 | source = "registry+https://github.com/rust-lang/crates.io-index" | 163 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -140,6 +174,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
140 | checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" | 174 | checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" |
141 | 175 | ||
142 | [[package]] | 176 | [[package]] |
177 | name = "either" | ||
178 | version = "1.6.1" | ||
179 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
180 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" | ||
181 | |||
182 | [[package]] | ||
143 | name = "encode_unicode" | 183 | name = "encode_unicode" |
144 | version = "0.3.6" | 184 | version = "0.3.6" |
145 | source = "registry+https://github.com/rust-lang/crates.io-index" | 185 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -323,6 +363,16 @@ dependencies = [ | |||
323 | ] | 363 | ] |
324 | 364 | ||
325 | [[package]] | 365 | [[package]] |
366 | name = "num_cpus" | ||
367 | version = "1.13.1" | ||
368 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
369 | checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" | ||
370 | dependencies = [ | ||
371 | "hermit-abi", | ||
372 | "libc", | ||
373 | ] | ||
374 | |||
375 | [[package]] | ||
326 | name = "once_cell" | 376 | name = "once_cell" |
327 | version = "1.8.0" | 377 | version = "1.8.0" |
328 | source = "registry+https://github.com/rust-lang/crates.io-index" | 378 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -380,6 +430,31 @@ dependencies = [ | |||
380 | ] | 430 | ] |
381 | 431 | ||
382 | [[package]] | 432 | [[package]] |
433 | name = "rayon" | ||
434 | version = "1.5.1" | ||
435 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
436 | checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" | ||
437 | dependencies = [ | ||
438 | "autocfg", | ||
439 | "crossbeam-deque", | ||
440 | "either", | ||
441 | "rayon-core", | ||
442 | ] | ||
443 | |||
444 | [[package]] | ||
445 | name = "rayon-core" | ||
446 | version = "1.9.1" | ||
447 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
448 | checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" | ||
449 | dependencies = [ | ||
450 | "crossbeam-channel", | ||
451 | "crossbeam-deque", | ||
452 | "crossbeam-utils", | ||
453 | "lazy_static", | ||
454 | "num_cpus", | ||
455 | ] | ||
456 | |||
457 | [[package]] | ||
383 | name = "regex" | 458 | name = "regex" |
384 | version = "1.5.4" | 459 | version = "1.5.4" |
385 | source = "registry+https://github.com/rust-lang/crates.io-index" | 460 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -442,6 +517,12 @@ dependencies = [ | |||
442 | ] | 517 | ] |
443 | 518 | ||
444 | [[package]] | 519 | [[package]] |
520 | name = "scopeguard" | ||
521 | version = "1.1.0" | ||
522 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
523 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" | ||
524 | |||
525 | [[package]] | ||
445 | name = "serde" | 526 | name = "serde" |
446 | version = "1.0.130" | 527 | version = "1.0.130" |
447 | source = "registry+https://github.com/rust-lang/crates.io-index" | 528 | source = "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" | |||
672 | version = "0.0.0" | 754 | version = "0.0.0" |
673 | dependencies = [ | 755 | dependencies = [ |
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] |
18 | ariadne = "0.1.3" | 18 | ariadne = "0.1.3" |
19 | rnix = "0.10.1" | ||
20 | clap = "3.0.0-beta.4" | 19 | clap = "3.0.0-beta.4" |
21 | ignore = "0.4.18" | 20 | ignore = "0.4.18" |
22 | thiserror = "1.0.30" | ||
23 | similar = "2.1.0" | ||
24 | vfs = { path = "../vfs" } | ||
25 | lib = { path = "../lib" } | 21 | lib = { path = "../lib" } |
22 | rayon = "1.5.1" | ||
23 | rnix = "0.10.1" | ||
24 | similar = "2.1.0" | ||
25 | thiserror = "1.0.30" | ||
26 | toml = "0.5.8" | 26 | toml = "0.5.8" |
27 | vfs = { path = "../vfs" } | ||
27 | 28 | ||
28 | [dependencies.serde] | 29 | [dependencies.serde] |
29 | version = "1.0.68" | 30 | version = "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 | } |
@@ -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": { |
@@ -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 | ||
204 | unsafe impl Send for Suggestion {} | ||
205 | |||
204 | #[cfg(feature = "json-out")] | 206 | #[cfg(feature = "json-out")] |
205 | impl Serialize for Suggestion { | 207 | impl 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] |
8 | indexmap = "1.6.2" | 8 | indexmap = "1.6.2" |
9 | 9 | rayon = "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 | ||
7 | use indexmap::IndexSet; | 7 | use indexmap::IndexSet; |
8 | use rayon::prelude::*; | ||
8 | 9 | ||
9 | #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] | 10 | #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] |
10 | pub struct FileId(pub u32); | 11 | pub 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 | ||
75 | pub struct VfsEntry<'ρ> { | 83 | pub struct VfsEntry<'ρ> { |