Skip to content

Commit b511753

Browse files
committed
Auto merge of rust-lang#130812 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? `@ghost`
2 parents 38352b0 + 35bc50f commit b511753

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

Diff for: src/tools/rust-analyzer/.typos.toml

+1
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

Diff for: src/tools/rust-analyzer/Cargo.lock

+38-19
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ version = "2.6.0"
9696
source = "registry+https://github.com/rust-lang/crates.io-index"
9797
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
9898

99+
[[package]]
100+
name = "borsh"
101+
version = "1.5.1"
102+
source = "registry+https://github.com/rust-lang/crates.io-index"
103+
checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed"
104+
dependencies = [
105+
"cfg_aliases 0.2.1",
106+
]
107+
99108
[[package]]
100109
name = "byteorder"
101110
version = "1.5.0"
@@ -167,6 +176,12 @@ version = "0.1.1"
167176
source = "registry+https://github.com/rust-lang/crates.io-index"
168177
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
169178

179+
[[package]]
180+
name = "cfg_aliases"
181+
version = "0.2.1"
182+
source = "registry+https://github.com/rust-lang/crates.io-index"
183+
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
184+
170185
[[package]]
171186
name = "chalk-derive"
172187
version = "0.98.0"
@@ -982,7 +997,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
982997

983998
[[package]]
984999
name = "lsp-server"
985-
version = "0.7.6"
1000+
version = "0.7.7"
9861001
dependencies = [
9871002
"crossbeam-channel",
9881003
"ctrlc",
@@ -994,9 +1009,9 @@ dependencies = [
9941009

9951010
[[package]]
9961011
name = "lsp-server"
997-
version = "0.7.6"
1012+
version = "0.7.7"
9981013
source = "registry+https://github.com/rust-lang/crates.io-index"
999-
checksum = "248f65b78f6db5d8e1b1604b4098a28b43d21a8eb1deeca22b1c421b276c7095"
1014+
checksum = "550446e84739dcaf6d48a4a093973850669e13e8a34d8f8d64851041be267cd9"
10001015
dependencies = [
10011016
"crossbeam-channel",
10021017
"log",
@@ -1029,8 +1044,10 @@ version = "0.0.0"
10291044
dependencies = [
10301045
"arrayvec",
10311046
"cov-mark",
1047+
"expect-test",
10321048
"intern",
10331049
"parser",
1050+
"ra-ap-rustc_lexer",
10341051
"rustc-hash",
10351052
"smallvec",
10361053
"span",
@@ -1113,7 +1130,7 @@ checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
11131130
dependencies = [
11141131
"bitflags 2.6.0",
11151132
"cfg-if",
1116-
"cfg_aliases",
1133+
"cfg_aliases 0.1.1",
11171134
"libc",
11181135
]
11191136

@@ -1468,9 +1485,9 @@ dependencies = [
14681485

14691486
[[package]]
14701487
name = "ra-ap-rustc_abi"
1471-
version = "0.63.0"
1488+
version = "0.68.0"
14721489
source = "registry+https://github.com/rust-lang/crates.io-index"
1473-
checksum = "b011c39d409940a890414e3a7b239762ac16d88029ad71b050a8374831b93790"
1490+
checksum = "2a8cb51bb4534ac3e9c74f1d9bd90e607e60f94f734b1cf1a66f753ad2af6ed7"
14741491
dependencies = [
14751492
"bitflags 2.6.0",
14761493
"ra-ap-rustc_index",
@@ -1479,9 +1496,9 @@ dependencies = [
14791496

14801497
[[package]]
14811498
name = "ra-ap-rustc_index"
1482-
version = "0.63.0"
1499+
version = "0.68.0"
14831500
source = "registry+https://github.com/rust-lang/crates.io-index"
1484-
checksum = "9027acdee649b0b27eb10b7db5be833efee3362d394935c5eed8f0745a9d43ce"
1501+
checksum = "8b640fba2b7ef4f875459e2e76daeb846ef341d1d376fa758962ac0eba79bce6"
14851502
dependencies = [
14861503
"arrayvec",
14871504
"ra-ap-rustc_index_macros",
@@ -1490,9 +1507,9 @@ dependencies = [
14901507

14911508
[[package]]
14921509
name = "ra-ap-rustc_index_macros"
1493-
version = "0.63.0"
1510+
version = "0.68.0"
14941511
source = "registry+https://github.com/rust-lang/crates.io-index"
1495-
checksum = "540b86dc0384141ac8e825fc2874cd44bffd4277d99d8ec63ee416f1a98d5997"
1512+
checksum = "faef502419ba5ac9d3079b1a835c6e5b4e605388254bbe55eb5683936f541be9"
14961513
dependencies = [
14971514
"proc-macro2",
14981515
"quote",
@@ -1501,29 +1518,29 @@ dependencies = [
15011518

15021519
[[package]]
15031520
name = "ra-ap-rustc_lexer"
1504-
version = "0.63.0"
1521+
version = "0.68.0"
15051522
source = "registry+https://github.com/rust-lang/crates.io-index"
1506-
checksum = "3bdf98bb457b47b9ae4aeebf867d0ca440c86925e0b6381658c4a02589748c9d"
1523+
checksum = "5da7f9d533b8d5be6704558da741ff20b982ad4647b1e9e08632853e4fecf9d5"
15071524
dependencies = [
15081525
"unicode-properties",
15091526
"unicode-xid",
15101527
]
15111528

15121529
[[package]]
15131530
name = "ra-ap-rustc_parse_format"
1514-
version = "0.63.0"
1531+
version = "0.68.0"
15151532
source = "registry+https://github.com/rust-lang/crates.io-index"
1516-
checksum = "e8fe3556ab6311bb775220563a300e2bf62ec56404521fe0c511a583937683d5"
1533+
checksum = "94389cf81c651b1bda9ac45d3de6a2d851bb6fd4cb893875daa44e419c94205f"
15171534
dependencies = [
15181535
"ra-ap-rustc_index",
15191536
"ra-ap-rustc_lexer",
15201537
]
15211538

15221539
[[package]]
15231540
name = "ra-ap-rustc_pattern_analysis"
1524-
version = "0.63.0"
1541+
version = "0.68.0"
15251542
source = "registry+https://github.com/rust-lang/crates.io-index"
1526-
checksum = "1709080fdeb5db630e1c2644026c2962aaa32416cd92f0190c04b0c21e114b91"
1543+
checksum = "3679d8dd0114ed6000918309f843782738e51c99d8e4baec0d0f706e4d948819"
15271544
dependencies = [
15281545
"ra-ap-rustc_index",
15291546
"rustc-hash",
@@ -1636,7 +1653,7 @@ dependencies = [
16361653
"intern",
16371654
"itertools",
16381655
"load-cargo",
1639-
"lsp-server 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
1656+
"lsp-server 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
16401657
"lsp-types",
16411658
"memchr",
16421659
"mimalloc",
@@ -1843,10 +1860,11 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
18431860

18441861
[[package]]
18451862
name = "smol_str"
1846-
version = "0.2.2"
1863+
version = "0.3.1"
18471864
source = "registry+https://github.com/rust-lang/crates.io-index"
1848-
checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead"
1865+
checksum = "66eaf762c5af19db3108300515c8aa7a50efc90ff745f4c62288052ebf9fdd25"
18491866
dependencies = [
1867+
"borsh",
18501868
"serde",
18511869
]
18521870

@@ -2607,6 +2625,7 @@ version = "0.1.0"
26072625
dependencies = [
26082626
"anyhow",
26092627
"directories",
2628+
"either",
26102629
"flate2",
26112630
"itertools",
26122631
"proc-macro2",

Diff for: src/tools/rust-analyzer/Cargo.toml

+7-6
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

Diff for: src/tools/rust-analyzer/crates/base-db/src/change.rs

+13-1
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

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

+11-65
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)