Skip to content

Commit a6d2117

Browse files
committed
Auto merge of #130812 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents 34842bc + f84aa5d commit a6d2117

File tree

247 files changed

+14436
-22697
lines changed

Some content is hidden

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

247 files changed

+14436
-22697
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extend-ignore-re = [
1515
'"flate2"',
1616
"raison d'être",
1717
"inout",
18+
"INOUT",
1819
"optin"
1920
]
2021

Cargo.lock

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

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
8585
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8686
vfs = { path = "./crates/vfs", version = "0.0.0" }
8787

88-
ra-ap-rustc_lexer = { version = "0.63.0", default-features = false }
89-
ra-ap-rustc_parse_format = { version = "0.63.0", default-features = false }
90-
ra-ap-rustc_index = { version = "0.63.0", default-features = false }
91-
ra-ap-rustc_abi = { version = "0.63.0", default-features = false }
92-
ra-ap-rustc_pattern_analysis = { version = "0.63.0", default-features = false }
88+
ra-ap-rustc_lexer = { version = "0.68.0", default-features = false }
89+
ra-ap-rustc_parse_format = { version = "0.68.0", default-features = false }
90+
ra-ap-rustc_index = { version = "0.68.0", default-features = false }
91+
ra-ap-rustc_abi = { version = "0.68.0", default-features = false }
92+
ra-ap-rustc_pattern_analysis = { version = "0.68.0", default-features = false }
9393

9494
# local crates that aren't published to crates.io. These should not have versions.
9595
test-fixture = { path = "./crates/test-fixture" }
@@ -145,7 +145,7 @@ smallvec = { version = "1.10.0", features = [
145145
"union",
146146
"const_generics",
147147
] }
148-
smol_str = "0.2.1"
148+
smol_str = "0.3.1"
149149
snap = "1.1.0"
150150
text-size = "1.1.1"
151151
tracing = "0.1.40"
@@ -185,6 +185,7 @@ style = { level = "warn", priority = -1 }
185185
suspicious = { level = "warn", priority = -1 }
186186

187187
## allow following lints
188+
too_long_first_doc_paragraph = "allow"
188189
# subjective
189190
single_match = "allow"
190191
# () makes a fine error in most cases

crates/base-db/src/change.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
44
use std::fmt;
55

6+
use rustc_hash::FxHashMap;
67
use salsa::Durability;
78
use triomphe::Arc;
89
use vfs::FileId;
910

10-
use crate::{CrateGraph, SourceDatabaseFileInputExt, SourceRoot, SourceRootDatabase, SourceRootId};
11+
use crate::{
12+
CrateGraph, CrateId, CrateWorkspaceData, SourceDatabaseFileInputExt, SourceRoot,
13+
SourceRootDatabase, SourceRootId,
14+
};
1115

1216
/// Encapsulate a bunch of raw `.set` calls on the database.
1317
#[derive(Default)]
1418
pub struct FileChange {
1519
pub roots: Option<Vec<SourceRoot>>,
1620
pub files_changed: Vec<(FileId, Option<String>)>,
1721
pub crate_graph: Option<CrateGraph>,
22+
pub ws_data: Option<FxHashMap<CrateId, Arc<CrateWorkspaceData>>>,
1823
}
1924

2025
impl fmt::Debug for FileChange {
@@ -50,6 +55,10 @@ impl FileChange {
5055
self.crate_graph = Some(graph);
5156
}
5257

58+
pub fn set_ws_data(&mut self, data: FxHashMap<CrateId, Arc<CrateWorkspaceData>>) {
59+
self.ws_data = Some(data);
60+
}
61+
5362
pub fn apply(self, db: &mut dyn SourceRootDatabase) {
5463
let _p = tracing::info_span!("FileChange::apply").entered();
5564
if let Some(roots) = self.roots {
@@ -74,6 +83,9 @@ impl FileChange {
7483
if let Some(crate_graph) = self.crate_graph {
7584
db.set_crate_graph_with_durability(Arc::new(crate_graph), Durability::HIGH);
7685
}
86+
if let Some(data) = self.ws_data {
87+
db.set_crate_workspace_data_with_durability(Arc::new(data), Durability::HIGH);
88+
}
7789
}
7890
}
7991

crates/base-db/src/input.rs

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -374,64 +374,24 @@ impl CrateGraph {
374374
self.arena.alloc(data)
375375
}
376376

377-
/// Remove the crate from crate graph. If any crates depend on this crate, the dependency would be replaced
378-
/// with the second input.
379-
pub fn remove_and_replace(
380-
&mut self,
381-
id: CrateId,
382-
replace_with: CrateId,
383-
) -> Result<(), CyclicDependenciesError> {
384-
for (x, data) in self.arena.iter() {
385-
if x == id {
386-
continue;
387-
}
388-
for edge in &data.dependencies {
389-
if edge.crate_id == id {
390-
self.check_cycle_after_dependency(edge.crate_id, replace_with)?;
391-
}
392-
}
393-
}
394-
// if everything was ok, start to replace
395-
for (x, data) in self.arena.iter_mut() {
396-
if x == id {
397-
continue;
398-
}
399-
for edge in &mut data.dependencies {
400-
if edge.crate_id == id {
401-
edge.crate_id = replace_with;
402-
}
403-
}
404-
}
405-
Ok(())
406-
}
407-
408377
pub fn add_dep(
409378
&mut self,
410379
from: CrateId,
411380
dep: Dependency,
412381
) -> Result<(), CyclicDependenciesError> {
413382
let _p = tracing::info_span!("add_dep").entered();
414383

415-
self.check_cycle_after_dependency(from, dep.crate_id)?;
416-
417-
self.arena[from].add_dep(dep);
418-
Ok(())
419-
}
420-
421-
/// Check if adding a dep from `from` to `to` creates a cycle. To figure
422-
/// that out, look for a path in the *opposite* direction, from `to` to
423-
/// `from`.
424-
fn check_cycle_after_dependency(
425-
&self,
426-
from: CrateId,
427-
to: CrateId,
428-
) -> Result<(), CyclicDependenciesError> {
429-
if let Some(path) = self.find_path(&mut FxHashSet::default(), to, from) {
384+
// Check if adding a dep from `from` to `to` creates a cycle. To figure
385+
// that out, look for a path in the *opposite* direction, from `to` to
386+
// `from`.
387+
if let Some(path) = self.find_path(&mut FxHashSet::default(), dep.crate_id, from) {
430388
let path = path.into_iter().map(|it| (it, self[it].display_name.clone())).collect();
431389
let err = CyclicDependenciesError { path };
432-
assert!(err.from().0 == from && err.to().0 == to);
390+
assert!(err.from().0 == from && err.to().0 == dep.crate_id);
433391
return Err(err);
434392
}
393+
394+
self.arena[from].add_dep(dep);
435395
Ok(())
436396
}
437397

@@ -531,43 +491,29 @@ impl CrateGraph {
531491
.for_each(|(_, data)| data.dependencies.sort_by_key(|dep| dep.crate_id));
532492
}
533493

534-
/// Extends this crate graph by adding a complete disjoint second crate
494+
/// Extends this crate graph by adding a complete second crate
535495
/// graph and adjust the ids in the [`ProcMacroPaths`] accordingly.
536496
///
537-
/// This will deduplicate the crates of the graph where possible.
538-
/// Note that for deduplication to fully work, `self`'s crate dependencies must be sorted by crate id.
539-
/// If the crate dependencies were sorted, the resulting graph from this `extend` call will also
540-
/// have the crate dependencies sorted.
541-
///
542-
/// Returns a mapping from `other`'s crate ids to the new crate ids in `self`.
497+
/// Returns a map mapping `other`'s IDs to the new IDs in `self`.
543498
pub fn extend(
544499
&mut self,
545500
mut other: CrateGraph,
546501
proc_macros: &mut ProcMacroPaths,
547-
merge: impl Fn((CrateId, &mut CrateData), (CrateId, &CrateData)) -> bool,
548502
) -> FxHashMap<CrateId, CrateId> {
549-
let m = self.len();
550503
let topo = other.crates_in_topological_order();
551504
let mut id_map: FxHashMap<CrateId, CrateId> = FxHashMap::default();
552505
for topo in topo {
553506
let crate_data = &mut other.arena[topo];
554507

555508
crate_data.dependencies.iter_mut().for_each(|dep| dep.crate_id = id_map[&dep.crate_id]);
556509
crate_data.dependencies.sort_by_key(|dep| dep.crate_id);
557-
let res = self
558-
.arena
559-
.iter_mut()
560-
.take(m)
561-
.find_map(|(id, data)| merge((id, data), (topo, crate_data)).then_some(id));
562-
563-
let new_id =
564-
if let Some(res) = res { res } else { self.arena.alloc(crate_data.clone()) };
510+
511+
let new_id = self.arena.alloc(crate_data.clone());
565512
id_map.insert(topo, new_id);
566513
}
567514

568515
*proc_macros =
569516
mem::take(proc_macros).into_iter().map(|(id, macros)| (id_map[&id], macros)).collect();
570-
571517
id_map
572518
}
573519

0 commit comments

Comments
 (0)