Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit f95b137

Browse files
authored
Merge pull request #1509 from Xanewok/configurable-blacklist
Make crate blacklist user-configurable
2 parents d099747 + dc3cee9 commit f95b137

File tree

17 files changed

+103
-324
lines changed

17 files changed

+103
-324
lines changed

Cargo.lock

Lines changed: 3 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ test = false
2121
path = "rls/src/main.rs"
2222

2323
[dependencies]
24-
rls-analysis = "0.17.0"
25-
rls-blacklist = "0.1.3"
24+
rls-analysis = "0.18.0"
2625
rls-data = "0.19"
2726
# FIXME: Release rls-rustc 0.6.0 to crates.io
2827
rls-rustc = { version = "0.6.0", path = "rls-rustc" }

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ Currently we accept the following options:
115115
* `all_targets` (`bool`, defaults to `true`) checks the project as if you were
116116
running `cargo check --all-targets`. I.e., check all targets and integration
117117
tests too
118-
* `use_crate_blacklist` (`bool`, defaults to `true`) if disabled, also indexes
119-
data from the [blacklisted](https://github.com/nrc/rls-blacklist/blob/master/src/lib.rs) crates
118+
* `crate_blacklist` (`[String]`, defaults to [this list](https://github.com/rust-dev-tools/rls-blacklist/blob/master/src/lib.rs))
119+
allows to specify which crates should be skipped by the RLS.
120+
By default skips libraries that are of considerable size but which the user
121+
often may not be directly interested in, thus reducing the build latency.
120122
* `build_on_save` (`bool`, defaults to `false`) toggles whether the RLS should
121123
perform continuous analysis or only after a file is saved
122124
* `features` (`[String]`, defaults to empty) list of Cargo features to enable

rls-analysis/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rls-analysis"
3-
version = "0.17.0"
3+
version = "0.18.0"
44
edition = "2018"
55
authors = ["Nick Cameron <[email protected]>"]
66
description = "Library for processing rustc's save-analysis data for the RLS"

rls-analysis/examples/print-crate-id.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn main() {
4242
std::process::exit(1);
4343
}
4444
let loader = Loader::new(PathBuf::from(env::args().nth(1).unwrap()));
45-
let crates = rls_analysis::read_analysis_from_files(&loader, Default::default(), &[]);
45+
let crates =
46+
rls_analysis::read_analysis_from_files(&loader, Default::default(), &[] as &[&str]);
4647

4748
for krate in &crates {
4849
println!("Crate {:?} data version {:?}", krate.id, krate.analysis.version);

rls-analysis/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub use raw::{name_space_for_def_kind, read_analysis_from_files, Crate, CrateId,
2525
pub use symbol_query::SymbolQuery;
2626

2727
use std::collections::HashMap;
28+
use std::fmt::Debug;
2829
use std::path::{Path, PathBuf};
2930
use std::sync::Mutex;
3031
use std::time::{Instant, SystemTime};
@@ -85,8 +86,6 @@ impl Id {
8586
/// Used to indicate a missing index in the Id.
8687
pub const NULL: Id = Id(u64::MAX);
8788

88-
type Blacklist<'a> = &'a [&'static str];
89-
9089
macro_rules! clone_field {
9190
($field: ident) => {
9291
|x| x.$field.clone()
@@ -126,7 +125,7 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
126125
analysis: Vec<data::Analysis>,
127126
path_prefix: &Path,
128127
base_dir: &Path,
129-
blacklist: Blacklist<'_>,
128+
blacklist: &[impl AsRef<str> + Debug],
130129
) -> AResult<()> {
131130
self.reload_with_blacklist(path_prefix, base_dir, blacklist)?;
132131

@@ -143,14 +142,14 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
143142
}
144143

145144
pub fn reload(&self, path_prefix: &Path, base_dir: &Path) -> AResult<()> {
146-
self.reload_with_blacklist(path_prefix, base_dir, &[])
145+
self.reload_with_blacklist(path_prefix, base_dir, &[] as &[&str])
147146
}
148147

149148
pub fn reload_with_blacklist(
150149
&self,
151150
path_prefix: &Path,
152151
base_dir: &Path,
153-
blacklist: Blacklist<'_>,
152+
blacklist: &[impl AsRef<str> + Debug],
154153
) -> AResult<()> {
155154
trace!("reload_with_blacklist {:?} {:?} {:?}", path_prefix, base_dir, blacklist);
156155
let empty = self.analysis.lock()?.is_none();
@@ -173,14 +172,14 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
173172

174173
/// Reloads the entire project's analysis data.
175174
pub fn hard_reload(&self, path_prefix: &Path, base_dir: &Path) -> AResult<()> {
176-
self.hard_reload_with_blacklist(path_prefix, base_dir, &[])
175+
self.hard_reload_with_blacklist(path_prefix, base_dir, &[] as &[&str])
177176
}
178177

179178
pub fn hard_reload_with_blacklist(
180179
&self,
181180
path_prefix: &Path,
182181
base_dir: &Path,
183-
blacklist: Blacklist<'_>,
182+
blacklist: &[impl AsRef<str> + Debug],
184183
) -> AResult<()> {
185184
trace!("hard_reload {:?} {:?}", path_prefix, base_dir);
186185
// We're going to create a dummy AnalysisHost that we will fill with data,
@@ -542,7 +541,7 @@ impl<L: AnalysisLoader> AnalysisHost<L> {
542541

543542
impl ::std::fmt::Display for Id {
544543
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
545-
self.0.fmt(f)
544+
::std::fmt::Display::fmt(&self.0, f)
546545
}
547546
}
548547

rls-analysis/src/raw.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ pub use data::{
66
};
77

88
use std::collections::HashMap;
9+
use std::fmt::Debug;
910
use std::fs::File;
1011
use std::io::{self, Read};
1112
use std::path::{Path, PathBuf};
1213
use std::time::{Instant, SystemTime};
1314

1415
use crate::listings::{DirectoryListing, ListingKind};
15-
use crate::{AnalysisLoader, Blacklist};
16+
use crate::AnalysisLoader;
1617

1718
#[derive(Debug)]
1819
pub struct Crate {
@@ -45,7 +46,7 @@ impl Crate {
4546
pub fn read_analysis_from_files<L: AnalysisLoader>(
4647
loader: &L,
4748
crate_timestamps: HashMap<PathBuf, SystemTime>,
48-
crate_blacklist: Blacklist<'_>,
49+
crate_blacklist: &[impl AsRef<str> + Debug],
4950
) -> Vec<Crate> {
5051
let mut result = vec![];
5152

@@ -92,8 +93,8 @@ pub fn read_analysis_from_files<L: AnalysisLoader>(
9293
result
9394
}
9495

95-
fn ignore_data(file_name: &str, crate_blacklist: Blacklist<'_>) -> bool {
96-
crate_blacklist.iter().any(|name| file_name.starts_with(&format!("lib{}-", name)))
96+
fn ignore_data(file_name: &str, crate_blacklist: &[impl AsRef<str>]) -> bool {
97+
crate_blacklist.iter().any(|name| file_name.starts_with(&format!("lib{}-", name.as_ref())))
9798
}
9899

99100
fn read_file_contents(path: &Path) -> io::Result<String> {

rls-blacklist/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

rls-blacklist/Cargo.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)