Skip to content

Commit 6bbd106

Browse files
committed
Merge commit '9d8889cdfcc3aa0302353fc988ed21ff9bc9925c' into sync-from-ra
1 parent 3afeb24 commit 6bbd106

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

Cargo.lock

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

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"] }

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)

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

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

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(

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);

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

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)