Skip to content

Subtree update of rust-analyzer #119988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 73 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
7fee088
complete merge_nested_if with bugs.
l1nxy Dec 29, 2023
edb9ad2
apply to only has nested if.
l1nxy Jan 1, 2024
b6a14ce
fix doc test.
l1nxy Jan 1, 2024
a3be52c
tidy.
l1nxy Jan 1, 2024
161d305
use tail_expr().
l1nxy Jan 3, 2024
b83f487
Set the `in-rust-tree`` feature for all rust-analyzer{-proc-macro-srv…
Veykril Jan 4, 2024
ab22869
Imply sysroot-abi feature when in-rust-tree is set
Veykril Jan 1, 2024
d480525
Add extern crate rustc_driver to proc-macro-srv-cli
Veykril Jan 1, 2024
8390d2a
Set sysroot-abi flag for proc-macro-cli when in-rust-tree is set
Veykril Jan 4, 2024
79fa976
Set proc-macro-test/sysroot-abi with proc-macro-srv/sysroot-abi
Veykril Jan 4, 2024
08c44a6
fix ast::Path::segments implementation
davidsemakula Jan 6, 2024
6403dbf
fix ast::Path::segments callers that implicitly relied on behavior of…
davidsemakula Jan 6, 2024
89d6b01
remove unnecessary ast::Path::segments alternatives
davidsemakula Jan 6, 2024
872951d
Replace 'postorder' with 'reverse of preorder' to traverse the AST in…
roife Jan 6, 2024
ba952e6
Transform paths before make::fn_
roife Jan 6, 2024
3afeb24
Merge commit 'af40101841c45aa75b56f4e9ca745369da8fb4ba' into sync-fro…
lnicola Jan 8, 2024
7dd9f20
Builtin derives are hygienic
Veykril Jan 8, 2024
1c40ac7
VFS no longer stores all source files in memory
Veykril Jan 7, 2024
7220064
fix: Fix incorrect parsing error on method call on range
Veykril Jan 8, 2024
b97ab00
Split out rustc_lexer from rustc_dependencies
Veykril Jan 8, 2024
e25e0dd
Split out rustc_parse_format from rustc_dependencies
Veykril Jan 8, 2024
f972da7
Remove rustc_dependencies crate
Veykril Jan 8, 2024
df5c647
add notable_trait predicate to `CompletionRelevance`
dfireBird Jan 6, 2024
c1c2421
Auto merge of #16307 - Veykril:vfs2, r=lnicola
bors Jan 8, 2024
598511b
Auto merge of #16308 - Veykril:builtin-macro-hygiene, r=lnicola
bors Jan 8, 2024
d94f572
Remove newline and add dot
Urhengulas Jan 8, 2024
12e7aa3
Auto merge of #16313 - Urhengulas:tidy-syntax-docs, r=lnicola
bors Jan 8, 2024
c6a02e3
Merge branch 'release' into sync-from-rust
lnicola Jan 9, 2024
f52f2f9
Merge branch 'master' into sync-from-rust
lnicola Jan 9, 2024
0ae7373
Try to fix feature gates
lnicola Jan 9, 2024
b0b2b1c
Fix allow(dead_code)
lnicola Jan 9, 2024
4413aeb
Temporarily disable resolve_proc_macro test
lnicola Jan 9, 2024
f5f7dda
Auto merge of #16317 - lnicola:sync-from-rust, r=Veykril
bors Jan 9, 2024
3926ff5
Bump follow-redirects from 1.15.2 to 1.15.4 in /editors/code
dependabot[bot] Jan 9, 2024
e1c6748
fix: Differentiate between vfs config load and file changed events
Veykril Jan 9, 2024
a8c94ea
fix: Fix rust-analyzer-proc-macro-srv failing to spawn on windows
Veykril Jan 8, 2024
21a953f
Recognize proc macro server unexpectedly exiting and report the exit …
Veykril Jan 8, 2024
25f7146
Auto merge of #16311 - Veykril:rustc-deps, r=Veykril
bors Jan 9, 2024
c246ecf
Auto merge of #16310 - Veykril:range-access-parse, r=Veykril
bors Jan 9, 2024
acafce3
Auto merge of #16309 - Veykril:proc-macro-srv-err, r=Veykril
bors Jan 9, 2024
e3575a8
Auto merge of #16312 - Veykril:win-proc-macro-srv, r=Veykril
bors Jan 9, 2024
9e34e64
Auto merge of #16319 - Veykril:no-double-load, r=Veykril
bors Jan 9, 2024
bffafc4
Auto merge of #16318 - rust-lang:dependabot/npm_and_yarn/editors/code…
bors Jan 9, 2024
da6f7e2
Auto merge of #16275 - davidsemakula:ast-path-segments, r=Veykril
bors Jan 9, 2024
51ac6de
Auto merge of #16277 - roife:fix-issue16276, r=Veykril
bors Jan 9, 2024
06aaf20
Some minor perf improvements
Veykril Jan 9, 2024
9673915
Make `DefDatabase::lang_attr` transparent
Veykril Jan 9, 2024
4e16e0f
Don't allocate `DefDatabase::crate_lang_items` if its empty
Veykril Jan 9, 2024
c4b3075
Don't allocate `inherent_impls_in_block` and `trait_impls_in_block` i…
Veykril Jan 9, 2024
f8b130a
unreachable pub
Veykril Jan 9, 2024
ae6e737
Auto merge of #16329 - Veykril:perfperf, r=Veykril
bors Jan 9, 2024
beeaaf1
Mark unresolved associated item diagnostic as experimental
zheylmun Jan 9, 2024
bc54775
Preserve comments for extracted block expr in 'extract_function' assist
roife Jan 10, 2024
d327f30
Add test 'comments_in_block_expr' in in 'extract_function'
roife Jan 10, 2024
9c2d331
Bump salsa
Veykril Jan 10, 2024
f31b1fc
Auto merge of #16334 - Veykril:salsa, r=Veykril
bors Jan 10, 2024
5871b61
Auto merge of #16333 - roife:fix/issue-14371, r=Veykril
bors Jan 10, 2024
4b7b602
Remove sysroot-abi feature flag from proc-macro-test
Veykril Jan 5, 2024
00eb8ce
Auto merge of #16271 - Veykril:gate-proc-macro-test, r=Veykril
bors Jan 10, 2024
1c9bb31
Auto merge of #16209 - l1nxy:add-merge-nested-if, r=Veykril
bors Jan 10, 2024
257870e
add tests to verify relevance of notable traits and some refactors
dfireBird Jan 10, 2024
b201684
Auto merge of #16274 - dfireBird:completion_score, r=Veykril
bors Jan 10, 2024
1aff815
Set experimental field at diagnostic new instead of lib
zheylmun Jan 10, 2024
e5a1118
Auto merge of #16330 - zheylmun:master, r=Veykril
bors Jan 10, 2024
4d3a0dc
Replace SourceRootCrates hashset output with slice for deterministic …
Veykril Jan 10, 2024
e4344f5
Auto merge of #16339 - Veykril:hashmaps, r=Veykril
bors Jan 10, 2024
76aaf17
Suggest `pub(crate)` imports
Patryk27 Jan 5, 2024
d5366b5
Auto merge of #16265 - Patryk27:suggest-pub-crate-imports, r=Veykril
bors Jan 11, 2024
b6e6d5d
internal: Consider all kinds of explicit private imports in find_path
Veykril Jan 11, 2024
215ede8
fix: Fix nested includes resolving from the wrong base file
Veykril Jan 11, 2024
3e1ae6b
Auto merge of #16347 - Veykril:find-path, r=Veykril
bors Jan 11, 2024
9d8889c
Auto merge of #16348 - Veykril:nested-includes, r=Veykril
bors Jan 11, 2024
32bd51e
Merge commit '9d8889cdfcc3aa0302353fc988ed21ff9bc9925c' into sync-fro…
lnicola Jan 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ dependencies = [
"mbe",
"once_cell",
"profile",
"rustc-dependencies",
"ra-ap-rustc_abi",
"ra-ap-rustc_parse_format",
"rustc-hash",
"smallvec",
"span",
Expand Down Expand Up @@ -579,7 +580,8 @@ dependencies = [
"oorandom",
"profile",
"project-model",
"rustc-dependencies",
"ra-ap-rustc_abi",
"ra-ap-rustc_index",
"rustc-hash",
"scoped-tls",
"smallvec",
Expand Down Expand Up @@ -1196,7 +1198,7 @@ dependencies = [
"drop_bomb",
"expect-test",
"limit",
"rustc-dependencies",
"ra-ap-rustc_lexer",
"sourcegen",
"stdx",
]
Expand Down Expand Up @@ -1540,7 +1542,6 @@ dependencies = [
"profile",
"project-model",
"rayon",
"rustc-dependencies",
"rustc-hash",
"scip",
"serde",
Expand All @@ -1567,9 +1568,9 @@ dependencies = [

[[package]]
name = "rust-analyzer-salsa"
version = "0.17.0-pre.4"
version = "0.17.0-pre.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16c42b8737c320578b441a82daf7cdf8d897468de64e8a774fa54b53a50b6cc0"
checksum = "ca9d387a9801f4fb9b366789ad1bfc08448cafc49cf148d907cfcd88ab665d7f"
dependencies = [
"indexmap",
"lock_api",
Expand All @@ -1579,13 +1580,14 @@ dependencies = [
"rust-analyzer-salsa-macros",
"rustc-hash",
"smallvec",
"triomphe",
]

[[package]]
name = "rust-analyzer-salsa-macros"
version = "0.17.0-pre.4"
version = "0.17.0-pre.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db72b0883f3592ade2be15a10583c75e0b269ec26e1190800fda2e2ce5ae6634"
checksum = "a2035f385d7fae31e9b086f40b272ee1d79c484472f31c9a10348a406e841eaf"
dependencies = [
"heck",
"proc-macro2",
Expand All @@ -1599,16 +1601,6 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"

[[package]]
name = "rustc-dependencies"
version = "0.0.0"
dependencies = [
"ra-ap-rustc_abi",
"ra-ap-rustc_index",
"ra-ap-rustc_lexer",
"ra-ap-rustc_parse_format",
]

[[package]]
name = "rustc-hash"
version = "1.1.0"
Expand Down Expand Up @@ -1751,6 +1743,12 @@ dependencies = [
"vfs",
]

[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"

[[package]]
name = "static_assertions"
version = "1.1.0"
Expand Down Expand Up @@ -1808,9 +1806,9 @@ dependencies = [
"proc-macro2",
"profile",
"quote",
"ra-ap-rustc_lexer",
"rayon",
"rowan",
"rustc-dependencies",
"rustc-hash",
"smol_str",
"sourcegen",
Expand Down Expand Up @@ -2028,9 +2026,13 @@ dependencies = [

[[package]]
name = "triomphe"
version = "0.1.10"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c5a71827ac326072b6405552093e2ad2accd25a32fd78d4edc82d98c7f2409"
checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3"
dependencies = [
"serde",
"stable_deref_trait",
]

[[package]]
name = "tt"
Expand Down
8 changes: 6 additions & 2 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ toolchain = { path = "./crates/toolchain", version = "0.0.0" }
tt = { path = "./crates/tt", version = "0.0.0" }
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
vfs = { path = "./crates/vfs", version = "0.0.0" }
rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }

ra-ap-rustc_lexer = { version = "0.21.0", default-features = false }
ra-ap-rustc_parse_format = { version = "0.21.0", default-features = false }
ra-ap-rustc_index = { version = "0.21.0", default-features = false }
ra-ap-rustc_abi = { version = "0.21.0", default-features = false }

# local crates that aren't published to crates.io. These should not have versions.
sourcegen = { path = "./crates/sourcegen" }
Expand Down Expand Up @@ -108,7 +112,7 @@ itertools = "0.12.0"
libc = "0.2.150"
nohash-hasher = "0.2.0"
rayon = "1.8.0"
rust-analyzer-salsa = "0.17.0-pre.4"
rust-analyzer-salsa = "0.17.0-pre.5"
rustc-hash = "1.1.0"
semver = "1.0.14"
serde = { version = "1.0.192", features = ["derive"] }
Expand Down
18 changes: 10 additions & 8 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod change;

use std::panic;

use rustc_hash::FxHashSet;
use syntax::{ast, Parse, SourceFile};
use triomphe::Arc;

Expand Down Expand Up @@ -44,12 +43,13 @@ pub trait Upcast<T: ?Sized> {
}

pub const DEFAULT_PARSE_LRU_CAP: usize = 128;
pub const DEFAULT_BORROWCK_LRU_CAP: usize = 256;

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

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

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

fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<FxHashSet<CrateId>> {
fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<[CrateId]> {
let graph = db.crate_graph();
let res = graph
let mut crates = graph
.iter()
.filter(|&krate| {
let root_file = graph[krate].root_file_id;
db.file_source_root(root_file) == id
})
.collect();
Arc::new(res)
.collect::<Vec<_>>();
crates.sort();
crates.dedup();
crates.into_iter().collect()
}

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

fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]> {
let _p = profile::span("relevant_crates");
let source_root = self.0.file_source_root(file_id);
self.0.source_root_crates(source_root)
Expand Down
7 changes: 4 additions & 3 deletions src/tools/rust-analyzer/crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ smallvec.workspace = true
hashbrown.workspace = true
triomphe.workspace = true

rustc-dependencies.workspace = true
ra-ap-rustc_parse_format.workspace = true
ra-ap-rustc_abi.workspace = true

# local deps
stdx.workspace = true
Expand All @@ -53,7 +54,7 @@ test-utils.workspace = true
test-fixture.workspace = true

[features]
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
in-rust-tree = []

[lints]
workspace = true
workspace = true
9 changes: 8 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ impl Attrs {
})
}

pub fn has_doc_notable_trait(&self) -> bool {
self.by_key("doc").tt_values().any(|tt| {
tt.delimiter.kind == DelimiterKind::Parenthesis &&
matches!(&*tt.token_trees, [tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.text == "notable_trait")
})
}

pub fn doc_exprs(&self) -> impl Iterator<Item = DocExpr> + '_ {
self.by_key("doc").tt_values().map(DocExpr::parse)
}
Expand Down Expand Up @@ -355,7 +362,7 @@ fn parse_comma_sep<S>(subtree: &tt::Subtree<S>) -> Vec<SmolStr> {
}

impl AttrsWithOwner {
pub(crate) fn attrs_with_owner(db: &dyn DefDatabase, owner: AttrDefId) -> Self {
pub fn attrs_with_owner(db: &dyn DefDatabase, owner: AttrDefId) -> Self {
Self { attrs: db.attrs(owner), owner }
}

Expand Down
5 changes: 2 additions & 3 deletions src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,10 @@ impl ExprCollector<'_> {

let res = match self.def_map.modules[module]
.scope
.macro_invocations
.get(&InFile::new(outer_file, self.ast_id_map.ast_id_for_ptr(syntax_ptr)))
.macro_invoc(InFile::new(outer_file, self.ast_id_map.ast_id_for_ptr(syntax_ptr)))
{
// fast path, macro call is in a block module
Some(&call) => Ok(self.expander.enter_expand_id(self.db, call)),
Some(call) => Ok(self.expander.enter_expand_id(self.db, call)),
None => self.expander.enter_expand(self.db, mcall, |path| {
self.def_map
.resolve_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl ChildBySource for ItemScope {
self.impls().for_each(|imp| add_impl(db, res, file_id, imp));
self.extern_crate_decls().for_each(|ext| add_extern_crate(db, res, file_id, ext));
self.use_decls().for_each(|ext| add_use(db, res, file_id, ext));
self.unnamed_consts().for_each(|konst| {
self.unnamed_consts(db).for_each(|konst| {
let loc = konst.lookup(db);
if loc.id.file_id() == file_id {
res[keys::CONST].insert(loc.source(db).value, konst);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/data/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hir_expand::{
};
use intern::Interned;
use la_arena::{Arena, ArenaMap};
use rustc_dependencies::abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
use syntax::ast::{self, HasName, HasVisibility};
use triomphe::Arc;

Expand Down
7 changes: 2 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,10 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
#[salsa::invoke(AttrsWithOwner::attrs_query)]
fn attrs(&self, def: AttrDefId) -> Attrs;

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

#[salsa::transparent]
#[salsa::invoke(AttrsWithOwner::attrs_with_owner)]
fn attrs_with_owner(&self, def: AttrDefId) -> AttrsWithOwner;

// endregion:attrs

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

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

fn crate_supports_no_std(&self, crate_id: CrateId) -> bool;
}
Expand Down
Loading