Skip to content

Commit 9f2ef0f

Browse files
committed
Auto merge of #146805 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update Subtree update of `rust-analyzer` to rust-lang/rust-analyzer@0c62c01. Created using https://github.com/rust-lang/josh-sync. r? `@ghost`
2 parents b00998a + 0afd767 commit 9f2ef0f

File tree

359 files changed

+38648
-9251
lines changed

Some content is hidden

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

359 files changed

+38648
-9251
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 117 additions & 110 deletions
Large diffs are not rendered by default.

src/tools/rust-analyzer/Cargo.toml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ debug = 2
3737
[patch.'crates-io']
3838
# rowan = { path = "../rowan" }
3939

40-
# chalk-solve = { path = "../chalk/chalk-solve" }
4140
# chalk-ir = { path = "../chalk/chalk-ir" }
42-
# chalk-recursive = { path = "../chalk/chalk-recursive" }
4341
# chalk-derive = { path = "../chalk/chalk-derive" }
4442
# line-index = { path = "lib/line-index" }
4543
# la-arena = { path = "lib/la-arena" }
@@ -89,29 +87,30 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8987
vfs = { path = "./crates/vfs", version = "0.0.0" }
9088
edition = { path = "./crates/edition", version = "0.0.0" }
9189

92-
ra-ap-rustc_lexer = { version = "0.123", default-features = false }
93-
ra-ap-rustc_parse_format = { version = "0.121", default-features = false }
94-
ra-ap-rustc_index = { version = "0.123", default-features = false }
95-
ra-ap-rustc_abi = { version = "0.123", default-features = false }
96-
ra-ap-rustc_pattern_analysis = { version = "0.123", default-features = false }
90+
ra-ap-rustc_lexer = { version = "0.132", default-features = false }
91+
ra-ap-rustc_parse_format = { version = "0.132", default-features = false }
92+
ra-ap-rustc_index = { version = "0.132", default-features = false }
93+
ra-ap-rustc_abi = { version = "0.132", default-features = false }
94+
ra-ap-rustc_pattern_analysis = { version = "0.132", default-features = false }
95+
ra-ap-rustc_ast_ir = { version = "0.132", default-features = false }
96+
ra-ap-rustc_type_ir = { version = "0.132", default-features = false }
97+
ra-ap-rustc_next_trait_solver = { version = "0.132", default-features = false }
9798

9899
# local crates that aren't published to crates.io. These should not have versions.
99100

100101
# in-tree crates that are published separately and follow semver. See lib/README.md
101102
line-index = { version = "0.1.2" }
102103
la-arena = { version = "0.3.1" }
103-
lsp-server = { version = "0.7.8" }
104+
lsp-server = { version = "0.7.9" }
104105

105106
# non-local crates
106107
anyhow = "1.0.98"
107108
arrayvec = "0.7.6"
108109
bitflags = "2.9.1"
109110
cargo_metadata = "0.21.0"
110111
camino = "1.1.10"
111-
chalk-solve = { version = "0.103.0", default-features = false }
112-
chalk-ir = "0.103.0"
113-
chalk-recursive = { version = "0.103.0", default-features = false }
114-
chalk-derive = "0.103.0"
112+
chalk-ir = "0.104.0"
113+
chalk-derive = "0.104.0"
115114
crossbeam-channel = "0.5.15"
116115
dissimilar = "1.0.10"
117116
dot = "0.1.4"
@@ -125,11 +124,11 @@ memmap2 = "0.9.5"
125124
nohash-hasher = "0.2.0"
126125
oorandom = "11.1.5"
127126
object = { version = "0.36.7", default-features = false, features = [
128-
"std",
129-
"read_core",
130-
"elf",
131-
"macho",
132-
"pe",
127+
"std",
128+
"read_core",
129+
"elf",
130+
"macho",
131+
"pe",
133132
] }
134133
process-wrap = { version = "8.2.1", features = ["std"] }
135134
pulldown-cmark-to-cmark = "10.0.4"
@@ -139,9 +138,9 @@ rowan = "=0.15.15"
139138
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
140139
# on impls without it
141140
salsa = { version = "0.23.0", default-features = true, features = [
142-
"rayon",
143-
"salsa_unstable",
144-
"macros",
141+
"rayon",
142+
"salsa_unstable",
143+
"macros",
145144
] }
146145
salsa-macros = "0.23.0"
147146
semver = "1.0.26"
@@ -151,22 +150,22 @@ serde_json = "1.0.140"
151150
rustc-hash = "2.1.1"
152151
rustc-literal-escaper = "0.0.4"
153152
smallvec = { version = "1.15.1", features = [
154-
"const_new",
155-
"union",
156-
"const_generics",
153+
"const_new",
154+
"union",
155+
"const_generics",
157156
] }
158157
smol_str = "0.3.2"
159158
temp-dir = "0.1.16"
160159
text-size = "1.1.1"
161160
tracing = "0.1.41"
162161
tracing-tree = "0.4.0"
163-
tracing-subscriber = { version = "0.3.19", default-features = false, features = [
164-
"registry",
165-
"fmt",
166-
"local-time",
167-
"std",
168-
"time",
169-
"tracing-log",
162+
tracing-subscriber = { version = "0.3.20", default-features = false, features = [
163+
"registry",
164+
"fmt",
165+
"local-time",
166+
"std",
167+
"time",
168+
"tracing-log",
170169
] }
171170
triomphe = { version = "0.1.14", default-features = false, features = ["std"] }
172171
url = "2.5.4"
@@ -176,7 +175,7 @@ xshell = "0.2.7"
176175
dashmap = { version = "=6.1.0", features = ["raw-api", "inline"] }
177176
# We need to freeze the version of the crate, as it needs to match with dashmap
178177
hashbrown = { version = "0.14.*", features = [
179-
"inline-more",
178+
"inline-more",
180179
], default-features = false }
181180

182181
[workspace.lints.rust]

src/tools/rust-analyzer/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44
alt="rust-analyzer logo">
55
</p>
66

7-
rust-analyzer is a modular compiler frontend for the Rust language.
8-
It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.
7+
rust-analyzer is a language server that provides IDE functionality for
8+
writing Rust programs. You can use it with any editor that supports
9+
the [Language Server
10+
Protocol](https://microsoft.github.io/language-server-protocol/) (VS
11+
Code, Vim, Emacs, Zed, etc).
12+
13+
rust-analyzer features include go-to-definition, find-all-references,
14+
refactorings and code completion. rust-analyzer also supports
15+
integrated formatting (with rustfmt) and integrated diagnostics (with
16+
rustc and clippy).
17+
18+
Internally, rust-analyzer is structured as a set of libraries for
19+
analyzing Rust code. See
20+
[Architecture](https://rust-analyzer.github.io/book/contributing/architecture.html)
21+
in the manual.
922

1023
## Quick Start
1124

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,6 @@ impl CrateDisplayName {
295295
}
296296
}
297297

298-
pub type TargetLayoutLoadResult = Result<Arc<str>, Arc<str>>;
299-
300298
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
301299
pub enum ReleaseChannel {
302300
Stable,
@@ -929,7 +927,7 @@ mod tests {
929927
use super::{CrateGraphBuilder, CrateName, CrateOrigin, Edition::Edition2018, Env, FileId};
930928

931929
fn empty_ws_data() -> Arc<CrateWorkspaceData> {
932-
Arc::new(CrateWorkspaceData { data_layout: Err("".into()), toolchain: None })
930+
Arc::new(CrateWorkspaceData { target: Err("".into()), toolchain: None })
933931
}
934932

935933
#[test]

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

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ pub use salsa_macros;
66
// FIXME: Rename this crate, base db is non descriptive
77
mod change;
88
mod input;
9+
pub mod target;
910

10-
use std::{cell::RefCell, hash::BuildHasherDefault, panic, sync::Once};
11+
use std::{
12+
cell::RefCell,
13+
hash::BuildHasherDefault,
14+
panic,
15+
sync::{Once, atomic::AtomicUsize},
16+
};
1117

1218
pub use crate::{
1319
change::FileChange,
1420
input::{
1521
BuiltCrateData, BuiltDependency, Crate, CrateBuilder, CrateBuilderId, CrateDataBuilder,
1622
CrateDisplayName, CrateGraphBuilder, CrateName, CrateOrigin, CratesIdMap, CratesMap,
1723
DependencyBuilder, Env, ExtraCrateData, LangCrateOrigin, ProcMacroLoadingError,
18-
ProcMacroPaths, ReleaseChannel, SourceRoot, SourceRootId, TargetLayoutLoadResult,
19-
UniqueCrateData,
24+
ProcMacroPaths, ReleaseChannel, SourceRoot, SourceRootId, UniqueCrateData,
2025
},
2126
};
2227
use dashmap::{DashMap, mapref::entry::Entry};
@@ -30,6 +35,8 @@ use triomphe::Arc;
3035
pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet};
3136

3237
pub type FxIndexSet<T> = indexmap::IndexSet<T, rustc_hash::FxBuildHasher>;
38+
pub type FxIndexMap<K, V> =
39+
indexmap::IndexMap<K, V, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
3340

3441
#[macro_export]
3542
macro_rules! impl_intern_key {
@@ -326,13 +333,33 @@ pub trait SourceDatabase: salsa::Database {
326333

327334
#[doc(hidden)]
328335
fn crates_map(&self) -> Arc<CratesMap>;
336+
337+
fn nonce_and_revision(&self) -> (Nonce, salsa::Revision);
338+
}
339+
340+
static NEXT_NONCE: AtomicUsize = AtomicUsize::new(0);
341+
342+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
343+
pub struct Nonce(usize);
344+
345+
impl Default for Nonce {
346+
#[inline]
347+
fn default() -> Self {
348+
Nonce::new()
349+
}
350+
}
351+
352+
impl Nonce {
353+
#[inline]
354+
pub fn new() -> Nonce {
355+
Nonce(NEXT_NONCE.fetch_add(1, std::sync::atomic::Ordering::SeqCst))
356+
}
329357
}
330358

331359
/// Crate related data shared by the whole workspace.
332360
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
333361
pub struct CrateWorkspaceData {
334-
// FIXME: Consider removing this, making HirDatabase::target_data_layout an input query
335-
pub data_layout: TargetLayoutLoadResult,
362+
pub target: Result<target::TargetData, target::TargetLoadError>,
336363
/// Toolchain version used to compile the crate.
337364
pub toolchain: Option<Version>,
338365
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! Information about the target.
2+
3+
use std::fmt;
4+
5+
use triomphe::Arc;
6+
7+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8+
pub enum Arch {
9+
// Only what we need is present here.
10+
Wasm32,
11+
Wasm64,
12+
Other,
13+
}
14+
15+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
16+
pub struct TargetData {
17+
pub data_layout: Box<str>,
18+
pub arch: Arch,
19+
}
20+
21+
#[derive(Clone, PartialEq, Eq, Hash)]
22+
pub struct TargetLoadError(Arc<str>);
23+
24+
impl fmt::Debug for TargetLoadError {
25+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26+
fmt::Debug::fmt(&self.0, f)
27+
}
28+
}
29+
30+
impl fmt::Display for TargetLoadError {
31+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32+
fmt::Display::fmt(&self.0, f)
33+
}
34+
}
35+
36+
impl std::error::Error for TargetLoadError {}
37+
38+
impl From<String> for TargetLoadError {
39+
fn from(value: String) -> Self {
40+
Self(value.into())
41+
}
42+
}
43+
44+
impl From<&str> for TargetLoadError {
45+
fn from(value: &str) -> Self {
46+
Self(value.into())
47+
}
48+
}
49+
50+
pub type TargetLoadResult = Result<TargetData, TargetLoadError>;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ impl AttrsWithOwner {
554554
AdtId::UnionId(it) => attrs_from_ast_id_loc(db, it),
555555
},
556556
AttrDefId::TraitId(it) => attrs_from_ast_id_loc(db, it),
557-
AttrDefId::TraitAliasId(it) => attrs_from_ast_id_loc(db, it),
558557
AttrDefId::MacroId(it) => match it {
559558
MacroId::Macro2Id(it) => attrs_from_ast_id_loc(db, it),
560559
MacroId::MacroRulesId(it) => attrs_from_ast_id_loc(db, it),
@@ -659,7 +658,6 @@ impl AttrsWithOwner {
659658
AttrDefId::StaticId(id) => any_has_attrs(db, id),
660659
AttrDefId::ConstId(id) => any_has_attrs(db, id),
661660
AttrDefId::TraitId(id) => any_has_attrs(db, id),
662-
AttrDefId::TraitAliasId(id) => any_has_attrs(db, id),
663661
AttrDefId::TypeAliasId(id) => any_has_attrs(db, id),
664662
AttrDefId::MacroId(id) => match id {
665663
MacroId::Macro2Id(id) => any_has_attrs(db, id),

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::{
1515
EnumVariantId, EnumVariantLoc, ExternBlockId, ExternBlockLoc, ExternCrateId, ExternCrateLoc,
1616
FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalFieldId, Macro2Id, Macro2Loc,
1717
MacroExpander, MacroId, MacroRulesId, MacroRulesLoc, MacroRulesLocFlags, ProcMacroId,
18-
ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc, TraitAliasId, TraitAliasLoc, TraitId,
19-
TraitLoc, TypeAliasId, TypeAliasLoc, UnionId, UnionLoc, UseId, UseLoc, VariantId,
18+
ProcMacroLoc, StaticId, StaticLoc, StructId, StructLoc, TraitId, TraitLoc, TypeAliasId,
19+
TypeAliasLoc, UnionId, UnionLoc, UseId, UseLoc, VariantId,
2020
attr::{Attrs, AttrsWithOwner},
2121
expr_store::{
2222
Body, BodySourceMap, ExpressionStore, ExpressionStoreSourceMap, scope::ExprScopes,
@@ -28,7 +28,7 @@ use crate::{
2828
nameres::crate_def_map,
2929
signatures::{
3030
ConstSignature, EnumSignature, FunctionSignature, ImplSignature, StaticSignature,
31-
StructSignature, TraitAliasSignature, TraitSignature, TypeAliasSignature, UnionSignature,
31+
StructSignature, TraitSignature, TypeAliasSignature, UnionSignature,
3232
},
3333
tt,
3434
visibility::{self, Visibility},
@@ -69,9 +69,6 @@ pub trait InternDatabase: RootQueryDb {
6969
#[salsa::interned]
7070
fn intern_trait(&self, loc: TraitLoc) -> TraitId;
7171

72-
#[salsa::interned]
73-
fn intern_trait_alias(&self, loc: TraitAliasLoc) -> TraitAliasId;
74-
7572
#[salsa::interned]
7673
fn intern_type_alias(&self, loc: TypeAliasLoc) -> TypeAliasId;
7774

@@ -152,11 +149,6 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + SourceDatabase {
152149
self.function_signature_with_source_map(e).0
153150
}
154151

155-
#[salsa::tracked]
156-
fn trait_alias_signature(&self, e: TraitAliasId) -> Arc<TraitAliasSignature> {
157-
self.trait_alias_signature_with_source_map(e).0
158-
}
159-
160152
#[salsa::tracked]
161153
fn type_alias_signature(&self, e: TypeAliasId) -> Arc<TypeAliasSignature> {
162154
self.type_alias_signature_with_source_map(e).0
@@ -210,12 +202,6 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + SourceDatabase {
210202
e: FunctionId,
211203
) -> (Arc<FunctionSignature>, Arc<ExpressionStoreSourceMap>);
212204

213-
#[salsa::invoke(TraitAliasSignature::query)]
214-
fn trait_alias_signature_with_source_map(
215-
&self,
216-
e: TraitAliasId,
217-
) -> (Arc<TraitAliasSignature>, Arc<ExpressionStoreSourceMap>);
218-
219205
#[salsa::invoke(TypeAliasSignature::query)]
220206
fn type_alias_signature_with_source_map(
221207
&self,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub mod keys {
3333

3434
use crate::{
3535
BlockId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId, FieldId, FunctionId,
36-
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId,
37-
TraitAliasId, TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
36+
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId, TraitId,
37+
TypeAliasId, TypeOrConstParamId, UnionId, UseId,
3838
dyn_map::{DynMap, Policy},
3939
};
4040

@@ -48,7 +48,6 @@ pub mod keys {
4848
pub const IMPL: Key<ast::Impl, ImplId> = Key::new();
4949
pub const EXTERN_BLOCK: Key<ast::ExternBlock, ExternBlockId> = Key::new();
5050
pub const TRAIT: Key<ast::Trait, TraitId> = Key::new();
51-
pub const TRAIT_ALIAS: Key<ast::TraitAlias, TraitAliasId> = Key::new();
5251
pub const STRUCT: Key<ast::Struct, StructId> = Key::new();
5352
pub const UNION: Key<ast::Union, UnionId> = Key::new();
5453
pub const ENUM: Key<ast::Enum, EnumId> = Key::new();

0 commit comments

Comments
 (0)