Skip to content

Commit 367f2ad

Browse files
committed
⬆️ rust-analyzer
2 parents 0631ea5 + e8e598f commit 367f2ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2005
-865
lines changed

src/tools/rust-analyzer/Cargo.lock

+54-27
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,6 @@ dependencies = [
247247
"cfg-if",
248248
]
249249

250-
[[package]]
251-
name = "crossbeam"
252-
version = "0.8.2"
253-
source = "registry+https://github.com/rust-lang/crates.io-index"
254-
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
255-
dependencies = [
256-
"cfg-if",
257-
"crossbeam-channel",
258-
"crossbeam-deque",
259-
"crossbeam-epoch",
260-
"crossbeam-queue",
261-
"crossbeam-utils",
262-
]
263-
264250
[[package]]
265251
name = "crossbeam-channel"
266252
version = "0.5.6"
@@ -296,16 +282,6 @@ dependencies = [
296282
"scopeguard",
297283
]
298284

299-
[[package]]
300-
name = "crossbeam-queue"
301-
version = "0.3.6"
302-
source = "registry+https://github.com/rust-lang/crates.io-index"
303-
checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7"
304-
dependencies = [
305-
"cfg-if",
306-
"crossbeam-utils",
307-
]
308-
309285
[[package]]
310286
name = "crossbeam-utils"
311287
version = "0.8.11"
@@ -728,6 +704,7 @@ dependencies = [
728704
"ide-db",
729705
"itertools",
730706
"parser",
707+
"stdx",
731708
"syntax",
732709
"test-utils",
733710
"text-edit",
@@ -895,9 +872,9 @@ dependencies = [
895872

896873
[[package]]
897874
name = "lsp-types"
898-
version = "0.93.0"
875+
version = "0.93.1"
899876
source = "registry+https://github.com/rust-lang/crates.io-index"
900-
checksum = "70c74e2173b2b31f8655d33724b4b45ac13f439386f66290f539c22b144c2212"
877+
checksum = "a3bcfee315dde785ba887edb540b08765fd7df75a7d948844be6bf5712246734"
901878
dependencies = [
902879
"bitflags",
903880
"serde",
@@ -1178,7 +1155,6 @@ dependencies = [
11781155
name = "proc-macro-srv"
11791156
version = "0.0.0"
11801157
dependencies = [
1181-
"crossbeam",
11821158
"expect-test",
11831159
"libloading",
11841160
"mbe",
@@ -1254,6 +1230,26 @@ dependencies = [
12541230
"tracing",
12551231
]
12561232

1233+
[[package]]
1234+
name = "protobuf"
1235+
version = "3.1.0"
1236+
source = "registry+https://github.com/rust-lang/crates.io-index"
1237+
checksum = "4ee4a7d8b91800c8f167a6268d1a1026607368e1adc84e98fe044aeb905302f7"
1238+
dependencies = [
1239+
"once_cell",
1240+
"protobuf-support",
1241+
"thiserror",
1242+
]
1243+
1244+
[[package]]
1245+
name = "protobuf-support"
1246+
version = "3.1.0"
1247+
source = "registry+https://github.com/rust-lang/crates.io-index"
1248+
checksum = "8ca157fe12fc7ee2e315f2f735e27df41b3d97cdd70ea112824dac1ffb08ee1c"
1249+
dependencies = [
1250+
"thiserror",
1251+
]
1252+
12571253
[[package]]
12581254
name = "pulldown-cmark"
12591255
version = "0.9.2"
@@ -1385,6 +1381,7 @@ dependencies = [
13851381
"project-model",
13861382
"rayon",
13871383
"rustc-hash",
1384+
"scip",
13881385
"serde",
13891386
"serde_json",
13901387
"sourcegen",
@@ -1471,6 +1468,15 @@ dependencies = [
14711468
"winapi-util",
14721469
]
14731470

1471+
[[package]]
1472+
name = "scip"
1473+
version = "0.1.1"
1474+
source = "registry+https://github.com/rust-lang/crates.io-index"
1475+
checksum = "b2bfbb10286f69fad7c78db71004b7839bf957788359fe0c479f029f9849136b"
1476+
dependencies = [
1477+
"protobuf",
1478+
]
1479+
14741480
[[package]]
14751481
name = "scoped-tls"
14761482
version = "1.0.0"
@@ -1656,6 +1662,26 @@ version = "1.1.0"
16561662
source = "registry+https://github.com/rust-lang/crates.io-index"
16571663
checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a"
16581664

1665+
[[package]]
1666+
name = "thiserror"
1667+
version = "1.0.31"
1668+
source = "registry+https://github.com/rust-lang/crates.io-index"
1669+
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
1670+
dependencies = [
1671+
"thiserror-impl",
1672+
]
1673+
1674+
[[package]]
1675+
name = "thiserror-impl"
1676+
version = "1.0.31"
1677+
source = "registry+https://github.com/rust-lang/crates.io-index"
1678+
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
1679+
dependencies = [
1680+
"proc-macro2",
1681+
"quote",
1682+
"syn",
1683+
]
1684+
16591685
[[package]]
16601686
name = "thread_local"
16611687
version = "1.1.4"
@@ -1896,6 +1922,7 @@ dependencies = [
18961922
"indexmap",
18971923
"paths",
18981924
"rustc-hash",
1925+
"stdx",
18991926
]
19001927

19011928
[[package]]

src/tools/rust-analyzer/crates/base-db/src/input.rs

+28-12
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
use std::{fmt, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
1010

1111
use cfg::CfgOptions;
12-
use rustc_hash::{FxHashMap, FxHashSet};
12+
use rustc_hash::FxHashMap;
13+
use stdx::hash::{NoHashHashMap, NoHashHashSet};
1314
use syntax::SmolStr;
1415
use tt::Subtree;
15-
use vfs::{file_set::FileSet, FileId, VfsPath};
16+
use vfs::{file_set::FileSet, AnchoredPath, FileId, VfsPath};
1617

1718
/// Files are grouped into source roots. A source root is a directory on the
1819
/// file systems which is watched for changes. Typically it corresponds to a
@@ -31,22 +32,30 @@ pub struct SourceRoot {
3132
/// Libraries are considered mostly immutable, this assumption is used to
3233
/// optimize salsa's query structure
3334
pub is_library: bool,
34-
pub(crate) file_set: FileSet,
35+
file_set: FileSet,
3536
}
3637

3738
impl SourceRoot {
3839
pub fn new_local(file_set: FileSet) -> SourceRoot {
3940
SourceRoot { is_library: false, file_set }
4041
}
42+
4143
pub fn new_library(file_set: FileSet) -> SourceRoot {
4244
SourceRoot { is_library: true, file_set }
4345
}
46+
4447
pub fn path_for_file(&self, file: &FileId) -> Option<&VfsPath> {
4548
self.file_set.path_for_file(file)
4649
}
50+
4751
pub fn file_for_path(&self, path: &VfsPath) -> Option<&FileId> {
4852
self.file_set.file_for_path(path)
4953
}
54+
55+
pub fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
56+
self.file_set.resolve_path(path)
57+
}
58+
5059
pub fn iter(&self) -> impl Iterator<Item = FileId> + '_ {
5160
self.file_set.iter()
5261
}
@@ -72,12 +81,19 @@ impl SourceRoot {
7281
/// <https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/architecture.md#serialization>
7382
#[derive(Debug, Clone, Default /* Serialize, Deserialize */)]
7483
pub struct CrateGraph {
75-
arena: FxHashMap<CrateId, CrateData>,
84+
arena: NoHashHashMap<CrateId, CrateData>,
7685
}
7786

78-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
87+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
7988
pub struct CrateId(pub u32);
8089

90+
impl stdx::hash::NoHashHashable for CrateId {}
91+
impl std::hash::Hash for CrateId {
92+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
93+
self.0.hash(state);
94+
}
95+
}
96+
8197
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8298
pub struct CrateName(SmolStr);
8399

@@ -342,7 +358,7 @@ impl CrateGraph {
342358
// Check if adding a dep from `from` to `to` creates a cycle. To figure
343359
// that out, look for a path in the *opposite* direction, from `to` to
344360
// `from`.
345-
if let Some(path) = self.find_path(&mut FxHashSet::default(), dep.crate_id, from) {
361+
if let Some(path) = self.find_path(&mut NoHashHashSet::default(), dep.crate_id, from) {
346362
let path = path.into_iter().map(|it| (it, self[it].display_name.clone())).collect();
347363
let err = CyclicDependenciesError { path };
348364
assert!(err.from().0 == from && err.to().0 == dep.crate_id);
@@ -365,7 +381,7 @@ impl CrateGraph {
365381
/// including the crate itself.
366382
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
367383
let mut worklist = vec![of];
368-
let mut deps = FxHashSet::default();
384+
let mut deps = NoHashHashSet::default();
369385

370386
while let Some(krate) = worklist.pop() {
371387
if !deps.insert(krate) {
@@ -382,10 +398,10 @@ impl CrateGraph {
382398
/// including the crate itself.
383399
pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
384400
let mut worklist = vec![of];
385-
let mut rev_deps = FxHashSet::default();
401+
let mut rev_deps = NoHashHashSet::default();
386402
rev_deps.insert(of);
387403

388-
let mut inverted_graph = FxHashMap::<_, Vec<_>>::default();
404+
let mut inverted_graph = NoHashHashMap::<_, Vec<_>>::default();
389405
self.arena.iter().for_each(|(&krate, data)| {
390406
data.dependencies
391407
.iter()
@@ -409,7 +425,7 @@ impl CrateGraph {
409425
/// come before the crate itself).
410426
pub fn crates_in_topological_order(&self) -> Vec<CrateId> {
411427
let mut res = Vec::new();
412-
let mut visited = FxHashSet::default();
428+
let mut visited = NoHashHashSet::default();
413429

414430
for krate in self.arena.keys().copied() {
415431
go(self, &mut visited, &mut res, krate);
@@ -419,7 +435,7 @@ impl CrateGraph {
419435

420436
fn go(
421437
graph: &CrateGraph,
422-
visited: &mut FxHashSet<CrateId>,
438+
visited: &mut NoHashHashSet<CrateId>,
423439
res: &mut Vec<CrateId>,
424440
source: CrateId,
425441
) {
@@ -459,7 +475,7 @@ impl CrateGraph {
459475

460476
fn find_path(
461477
&self,
462-
visited: &mut FxHashSet<CrateId>,
478+
visited: &mut NoHashHashSet<CrateId>,
463479
from: CrateId,
464480
to: CrateId,
465481
) -> Option<Vec<CrateId>> {

src/tools/rust-analyzer/crates/base-db/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod fixture;
88

99
use std::{panic, sync::Arc};
1010

11-
use rustc_hash::FxHashSet;
11+
use stdx::hash::NoHashHashSet;
1212
use syntax::{ast, Parse, SourceFile, TextRange, TextSize};
1313

1414
pub use crate::{
@@ -58,7 +58,7 @@ pub trait FileLoader {
5858
/// Text of the file.
5959
fn file_text(&self, file_id: FileId) -> Arc<String>;
6060
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
61-
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
61+
fn relevant_crates(&self, file_id: FileId) -> Arc<NoHashHashSet<CrateId>>;
6262
}
6363

6464
/// Database which stores all significant input facts: source code and project
@@ -94,10 +94,10 @@ pub trait SourceDatabaseExt: SourceDatabase {
9494
#[salsa::input]
9595
fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
9696

97-
fn source_root_crates(&self, id: SourceRootId) -> Arc<FxHashSet<CrateId>>;
97+
fn source_root_crates(&self, id: SourceRootId) -> Arc<NoHashHashSet<CrateId>>;
9898
}
9999

100-
fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<FxHashSet<CrateId>> {
100+
fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<NoHashHashSet<CrateId>> {
101101
let graph = db.crate_graph();
102102
let res = graph
103103
.iter()
@@ -120,10 +120,10 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
120120
// FIXME: this *somehow* should be platform agnostic...
121121
let source_root = self.0.file_source_root(path.anchor);
122122
let source_root = self.0.source_root(source_root);
123-
source_root.file_set.resolve_path(path)
123+
source_root.resolve_path(path)
124124
}
125125

126-
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
126+
fn relevant_crates(&self, file_id: FileId) -> Arc<NoHashHashSet<CrateId>> {
127127
let _p = profile::span("relevant_crates");
128128
let source_root = self.0.file_source_root(file_id);
129129
self.0.source_root_crates(source_root)

src/tools/rust-analyzer/crates/flycheck/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub enum Progress {
125125
DidCheckCrate(String),
126126
DidFinish(io::Result<()>),
127127
DidCancel,
128+
DidFailToRestart(String),
128129
}
129130

130131
enum Restart {
@@ -193,10 +194,11 @@ impl FlycheckActor {
193194
self.progress(Progress::DidStart);
194195
}
195196
Err(error) => {
196-
tracing::error!(
197-
command = ?self.check_command(),
198-
%error, "failed to restart flycheck"
199-
);
197+
self.progress(Progress::DidFailToRestart(format!(
198+
"Failed to run the following command: {:?} error={}",
199+
self.check_command(),
200+
error
201+
)));
200202
}
201203
}
202204
}

0 commit comments

Comments
 (0)