Skip to content

Commit 28243a1

Browse files
committed
Auto merge of #101220 - JohnTitor:rollup-ov7upr7, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #100804 (Fix search results color on hover for ayu theme) - #100892 (Add `AsFd` implementations for stdio types on WASI.) - #100927 (Adding new Fuchsia rustup docs... reworking walkthrough) - #101088 (Set DebuginfoKind::Pdb in msvc_base) - #101159 (add tracking issue number to const_slice_split_at_not_mut) - #101192 (Remove path string) - #101193 (Avoid zeroing large stack buffers in stdio on Windows) - #101197 (:arrow_up: rust-analyzer) - #101200 (Add test for issue #85872) - #101219 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 79ebac7 + 572f5a3 commit 28243a1

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

Cargo.lock

+54-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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>> {

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)

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)