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

Commit 78664f4

Browse files
committed
Auto merge of #1312 - Xanewok:format-subcrates, r=alexheretic
Format all pulled subcrates #1304 but for pulled subcrates. r? @alexheretic
2 parents 6c0bbf5 + 95d0ed0 commit 78664f4

File tree

17 files changed

+433
-650
lines changed

17 files changed

+433
-650
lines changed

rls-analysis/benches/std_api_crate.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ impl AnalysisLoader for TestAnalysisLoader {
4949
lazy_static! {
5050
static ref STDLIB_FILE_PATH: PathBuf = PathBuf::from("/checkout/src/libstd/lib.rs");
5151
static ref STDLIB_DATA_PATH: PathBuf = PathBuf::from("test_data/rust-analysis");
52-
5352
static ref HOST: RwLock<AnalysisHost<TestAnalysisLoader>> = {
54-
let host = AnalysisHost::new_with_loader(TestAnalysisLoader::new(
55-
STDLIB_DATA_PATH.clone(),
56-
));
53+
let host = AnalysisHost::new_with_loader(TestAnalysisLoader::new(STDLIB_DATA_PATH.clone()));
5754
host.reload(&STDLIB_DATA_PATH, &STDLIB_DATA_PATH).unwrap();
5855
RwLock::new(host)
5956
};
@@ -73,7 +70,6 @@ fn search(b: &mut Bencher) {
7370
let host = HOST.read().unwrap();
7471
b.iter(|| {
7572
let _ = host.search("some_inexistent_symbol");
76-
7773
})
7874
}
7975

@@ -91,4 +87,4 @@ fn reload(b: &mut Bencher) {
9187
b.iter(|| {
9288
host.reload(&STDLIB_DATA_PATH, &STDLIB_DATA_PATH).unwrap();
9389
})
94-
}
90+
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
extern crate rls_analysis;
21
extern crate env_logger;
2+
extern crate rls_analysis;
33

44
use rls_analysis::{AnalysisHost, AnalysisLoader, SearchDirectory};
5-
use std::path::{Path, PathBuf};
65
use std::env;
6+
use std::path::{Path, PathBuf};
77

88
#[derive(Clone)]
99
pub struct Loader {
@@ -31,10 +31,7 @@ impl AnalysisLoader for Loader {
3131
None
3232
}
3333
fn search_directories(&self) -> Vec<SearchDirectory> {
34-
vec![SearchDirectory {
35-
path: self.deps_dir.clone(),
36-
prefix_rewrite: None,
37-
}]
34+
vec![SearchDirectory { path: self.deps_dir.clone(), prefix_rewrite: None }]
3835
}
3936
}
4037

rls-analysis/src/analysis.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
use fst;
910
use std::collections::{HashMap, HashSet};
11+
use std::iter;
1012
use std::path::{Path, PathBuf};
1113
use std::time::SystemTime;
12-
use std::iter;
13-
use fst;
1414

15-
use {Id, Span, SymbolQuery};
1615
use raw::{CrateId, DefKind};
16+
use {Id, Span, SymbolQuery};
1717

1818
/// This is the main database that contains all the collected symbol information,
1919
/// such as definitions, their mapping between spans, hierarchy and so on,
@@ -133,11 +133,9 @@ pub struct Glob {
133133
pub value: String,
134134
}
135135

136-
137136
impl PerCrateAnalysis {
138137
pub fn new(timestamp: SystemTime, path: Option<PathBuf>) -> PerCrateAnalysis {
139-
let empty_fst =
140-
fst::Map::from_iter(iter::empty::<(String, u64)>()).unwrap();
138+
let empty_fst = fst::Map::from_iter(iter::empty::<(String, u64)>()).unwrap();
141139
PerCrateAnalysis {
142140
def_id_for_span: HashMap::new(),
143141
defs: HashMap::new(),
@@ -244,14 +242,13 @@ impl Analysis {
244242
// crate.
245243
pub fn local_def_id_for_span(&self, span: &Span) -> Option<Id> {
246244
self.for_each_crate(|c| {
247-
c.def_id_for_span
248-
.get(span)
249-
.map(|r| r.some_id())
250-
.and_then(|id| if c.defs.contains_key(&id) {
245+
c.def_id_for_span.get(span).map(|r| r.some_id()).and_then(|id| {
246+
if c.defs.contains_key(&id) {
251247
Some(id)
252248
} else {
253249
None
254-
})
250+
}
251+
})
255252
})
256253
}
257254

@@ -316,19 +313,15 @@ impl Analysis {
316313

317314
pub fn query_defs(&self, query: SymbolQuery) -> Vec<Def> {
318315
let mut crates = Vec::with_capacity(self.per_crate.len());
319-
let stream = query.build_stream(
320-
self.per_crate.values().map(|c| {
321-
crates.push(c);
322-
&c.def_fst
323-
})
324-
);
316+
let stream = query.build_stream(self.per_crate.values().map(|c| {
317+
crates.push(c);
318+
&c.def_fst
319+
}));
325320

326321
query.search_stream(stream, |acc, e| {
327322
let c = &crates[e.index];
328323
let ids = &c.def_fst_values[e.value as usize];
329-
acc.extend(
330-
ids.iter().flat_map(|id| c.defs.get(id)).cloned()
331-
);
324+
acc.extend(ids.iter().flat_map(|id| c.defs.get(id)).cloned());
332325
})
333326
}
334327

0 commit comments

Comments
 (0)