Skip to content

Commit bfcc027

Browse files
committed
Auto merge of #119988 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer` r? ghost
2 parents 67e7b84 + 32bd51e commit bfcc027

File tree

104 files changed

+1650
-1024
lines changed

Some content is hidden

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

104 files changed

+1650
-1024
lines changed

src/tools/rust-analyzer/Cargo.lock

+23-21
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ dependencies = [
513513
"mbe",
514514
"once_cell",
515515
"profile",
516-
"rustc-dependencies",
516+
"ra-ap-rustc_abi",
517+
"ra-ap-rustc_parse_format",
517518
"rustc-hash",
518519
"smallvec",
519520
"span",
@@ -579,7 +580,8 @@ dependencies = [
579580
"oorandom",
580581
"profile",
581582
"project-model",
582-
"rustc-dependencies",
583+
"ra-ap-rustc_abi",
584+
"ra-ap-rustc_index",
583585
"rustc-hash",
584586
"scoped-tls",
585587
"smallvec",
@@ -1196,7 +1198,7 @@ dependencies = [
11961198
"drop_bomb",
11971199
"expect-test",
11981200
"limit",
1199-
"rustc-dependencies",
1201+
"ra-ap-rustc_lexer",
12001202
"sourcegen",
12011203
"stdx",
12021204
]
@@ -1540,7 +1542,6 @@ dependencies = [
15401542
"profile",
15411543
"project-model",
15421544
"rayon",
1543-
"rustc-dependencies",
15441545
"rustc-hash",
15451546
"scip",
15461547
"serde",
@@ -1567,9 +1568,9 @@ dependencies = [
15671568

15681569
[[package]]
15691570
name = "rust-analyzer-salsa"
1570-
version = "0.17.0-pre.4"
1571+
version = "0.17.0-pre.5"
15711572
source = "registry+https://github.com/rust-lang/crates.io-index"
1572-
checksum = "16c42b8737c320578b441a82daf7cdf8d897468de64e8a774fa54b53a50b6cc0"
1573+
checksum = "ca9d387a9801f4fb9b366789ad1bfc08448cafc49cf148d907cfcd88ab665d7f"
15731574
dependencies = [
15741575
"indexmap",
15751576
"lock_api",
@@ -1579,13 +1580,14 @@ dependencies = [
15791580
"rust-analyzer-salsa-macros",
15801581
"rustc-hash",
15811582
"smallvec",
1583+
"triomphe",
15821584
]
15831585

15841586
[[package]]
15851587
name = "rust-analyzer-salsa-macros"
1586-
version = "0.17.0-pre.4"
1588+
version = "0.17.0-pre.5"
15871589
source = "registry+https://github.com/rust-lang/crates.io-index"
1588-
checksum = "db72b0883f3592ade2be15a10583c75e0b269ec26e1190800fda2e2ce5ae6634"
1590+
checksum = "a2035f385d7fae31e9b086f40b272ee1d79c484472f31c9a10348a406e841eaf"
15891591
dependencies = [
15901592
"heck",
15911593
"proc-macro2",
@@ -1599,16 +1601,6 @@ version = "0.1.23"
15991601
source = "registry+https://github.com/rust-lang/crates.io-index"
16001602
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
16011603

1602-
[[package]]
1603-
name = "rustc-dependencies"
1604-
version = "0.0.0"
1605-
dependencies = [
1606-
"ra-ap-rustc_abi",
1607-
"ra-ap-rustc_index",
1608-
"ra-ap-rustc_lexer",
1609-
"ra-ap-rustc_parse_format",
1610-
]
1611-
16121604
[[package]]
16131605
name = "rustc-hash"
16141606
version = "1.1.0"
@@ -1751,6 +1743,12 @@ dependencies = [
17511743
"vfs",
17521744
]
17531745

1746+
[[package]]
1747+
name = "stable_deref_trait"
1748+
version = "1.2.0"
1749+
source = "registry+https://github.com/rust-lang/crates.io-index"
1750+
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
1751+
17541752
[[package]]
17551753
name = "static_assertions"
17561754
version = "1.1.0"
@@ -1808,9 +1806,9 @@ dependencies = [
18081806
"proc-macro2",
18091807
"profile",
18101808
"quote",
1809+
"ra-ap-rustc_lexer",
18111810
"rayon",
18121811
"rowan",
1813-
"rustc-dependencies",
18141812
"rustc-hash",
18151813
"smol_str",
18161814
"sourcegen",
@@ -2028,9 +2026,13 @@ dependencies = [
20282026

20292027
[[package]]
20302028
name = "triomphe"
2031-
version = "0.1.10"
2029+
version = "0.1.11"
20322030
source = "registry+https://github.com/rust-lang/crates.io-index"
2033-
checksum = "d0c5a71827ac326072b6405552093e2ad2accd25a32fd78d4edc82d98c7f2409"
2031+
checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3"
2032+
dependencies = [
2033+
"serde",
2034+
"stable_deref_trait",
2035+
]
20342036

20352037
[[package]]
20362038
name = "tt"

src/tools/rust-analyzer/Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ toolchain = { path = "./crates/toolchain", version = "0.0.0" }
7878
tt = { path = "./crates/tt", version = "0.0.0" }
7979
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8080
vfs = { path = "./crates/vfs", version = "0.0.0" }
81-
rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
81+
82+
ra-ap-rustc_lexer = { version = "0.21.0", default-features = false }
83+
ra-ap-rustc_parse_format = { version = "0.21.0", default-features = false }
84+
ra-ap-rustc_index = { version = "0.21.0", default-features = false }
85+
ra-ap-rustc_abi = { version = "0.21.0", default-features = false }
8286

8387
# local crates that aren't published to crates.io. These should not have versions.
8488
sourcegen = { path = "./crates/sourcegen" }
@@ -108,7 +112,7 @@ itertools = "0.12.0"
108112
libc = "0.2.150"
109113
nohash-hasher = "0.2.0"
110114
rayon = "1.8.0"
111-
rust-analyzer-salsa = "0.17.0-pre.4"
115+
rust-analyzer-salsa = "0.17.0-pre.5"
112116
rustc-hash = "1.1.0"
113117
semver = "1.0.14"
114118
serde = { version = "1.0.192", features = ["derive"] }

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

+10-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod change;
77

88
use std::panic;
99

10-
use rustc_hash::FxHashSet;
1110
use syntax::{ast, Parse, SourceFile};
1211
use triomphe::Arc;
1312

@@ -44,12 +43,13 @@ pub trait Upcast<T: ?Sized> {
4443
}
4544

4645
pub const DEFAULT_PARSE_LRU_CAP: usize = 128;
46+
pub const DEFAULT_BORROWCK_LRU_CAP: usize = 256;
4747

4848
pub trait FileLoader {
4949
/// Text of the file.
5050
fn file_text(&self, file_id: FileId) -> Arc<str>;
5151
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
52-
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
52+
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]>;
5353
}
5454

5555
/// Database which stores all significant input facts: source code and project
@@ -84,19 +84,21 @@ pub trait SourceDatabaseExt: SourceDatabase {
8484
#[salsa::input]
8585
fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
8686

87-
fn source_root_crates(&self, id: SourceRootId) -> Arc<FxHashSet<CrateId>>;
87+
fn source_root_crates(&self, id: SourceRootId) -> Arc<[CrateId]>;
8888
}
8989

90-
fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<FxHashSet<CrateId>> {
90+
fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<[CrateId]> {
9191
let graph = db.crate_graph();
92-
let res = graph
92+
let mut crates = graph
9393
.iter()
9494
.filter(|&krate| {
9595
let root_file = graph[krate].root_file_id;
9696
db.file_source_root(root_file) == id
9797
})
98-
.collect();
99-
Arc::new(res)
98+
.collect::<Vec<_>>();
99+
crates.sort();
100+
crates.dedup();
101+
crates.into_iter().collect()
100102
}
101103

102104
/// Silly workaround for cyclic deps between the traits
@@ -113,7 +115,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
113115
source_root.resolve_path(path)
114116
}
115117

116-
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
118+
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]> {
117119
let _p = profile::span("relevant_crates");
118120
let source_root = self.0.file_source_root(file_id);
119121
self.0.source_root_crates(source_root)

src/tools/rust-analyzer/crates/hir-def/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ smallvec.workspace = true
2929
hashbrown.workspace = true
3030
triomphe.workspace = true
3131

32-
rustc-dependencies.workspace = true
32+
ra-ap-rustc_parse_format.workspace = true
33+
ra-ap-rustc_abi.workspace = true
3334

3435
# local deps
3536
stdx.workspace = true
@@ -53,7 +54,7 @@ test-utils.workspace = true
5354
test-fixture.workspace = true
5455

5556
[features]
56-
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
57+
in-rust-tree = []
5758

5859
[lints]
59-
workspace = true
60+
workspace = true

src/tools/rust-analyzer/crates/hir-def/src/attr.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ impl Attrs {
207207
})
208208
}
209209

210+
pub fn has_doc_notable_trait(&self) -> bool {
211+
self.by_key("doc").tt_values().any(|tt| {
212+
tt.delimiter.kind == DelimiterKind::Parenthesis &&
213+
matches!(&*tt.token_trees, [tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.text == "notable_trait")
214+
})
215+
}
216+
210217
pub fn doc_exprs(&self) -> impl Iterator<Item = DocExpr> + '_ {
211218
self.by_key("doc").tt_values().map(DocExpr::parse)
212219
}
@@ -355,7 +362,7 @@ fn parse_comma_sep<S>(subtree: &tt::Subtree<S>) -> Vec<SmolStr> {
355362
}
356363

357364
impl AttrsWithOwner {
358-
pub(crate) fn attrs_with_owner(db: &dyn DefDatabase, owner: AttrDefId) -> Self {
365+
pub fn attrs_with_owner(db: &dyn DefDatabase, owner: AttrDefId) -> Self {
359366
Self { attrs: db.attrs(owner), owner }
360367
}
361368

src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -965,11 +965,10 @@ impl ExprCollector<'_> {
965965

966966
let res = match self.def_map.modules[module]
967967
.scope
968-
.macro_invocations
969-
.get(&InFile::new(outer_file, self.ast_id_map.ast_id_for_ptr(syntax_ptr)))
968+
.macro_invoc(InFile::new(outer_file, self.ast_id_map.ast_id_for_ptr(syntax_ptr)))
970969
{
971970
// fast path, macro call is in a block module
972-
Some(&call) => Ok(self.expander.enter_expand_id(self.db, call)),
971+
Some(call) => Ok(self.expander.enter_expand_id(self.db, call)),
973972
None => self.expander.enter_expand(self.db, mcall, |path| {
974973
self.def_map
975974
.resolve_path(

src/tools/rust-analyzer/crates/hir-def/src/child_by_source.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl ChildBySource for ItemScope {
9292
self.impls().for_each(|imp| add_impl(db, res, file_id, imp));
9393
self.extern_crate_decls().for_each(|ext| add_extern_crate(db, res, file_id, ext));
9494
self.use_decls().for_each(|ext| add_use(db, res, file_id, ext));
95-
self.unnamed_consts().for_each(|konst| {
95+
self.unnamed_consts(db).for_each(|konst| {
9696
let loc = konst.lookup(db);
9797
if loc.id.file_id() == file_id {
9898
res[keys::CONST].insert(loc.source(db).value, konst);

src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hir_expand::{
1111
};
1212
use intern::Interned;
1313
use la_arena::{Arena, ArenaMap};
14-
use rustc_dependencies::abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
14+
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
1515
use syntax::ast::{self, HasName, HasVisibility};
1616
use triomphe::Arc;
1717

src/tools/rust-analyzer/crates/hir-def/src/db.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,10 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
210210
#[salsa::invoke(AttrsWithOwner::attrs_query)]
211211
fn attrs(&self, def: AttrDefId) -> Attrs;
212212

213+
#[salsa::transparent]
213214
#[salsa::invoke(lang_item::lang_attr_query)]
214215
fn lang_attr(&self, def: AttrDefId) -> Option<LangItem>;
215216

216-
#[salsa::transparent]
217-
#[salsa::invoke(AttrsWithOwner::attrs_with_owner)]
218-
fn attrs_with_owner(&self, def: AttrDefId) -> AttrsWithOwner;
219-
220217
// endregion:attrs
221218

222219
#[salsa::invoke(LangItems::lang_item_query)]
@@ -240,7 +237,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
240237
// endregion:visibilities
241238

242239
#[salsa::invoke(LangItems::crate_lang_items_query)]
243-
fn crate_lang_items(&self, krate: CrateId) -> Arc<LangItems>;
240+
fn crate_lang_items(&self, krate: CrateId) -> Option<Arc<LangItems>>;
244241

245242
fn crate_supports_no_std(&self, crate_id: CrateId) -> bool;
246243
}

0 commit comments

Comments
 (0)