Skip to content

Subtree update of rust-analyzer #143565

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 63 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d02f6f2
format function
jnyfah Jun 18, 2025
8949360
fix format
jnyfah Jun 18, 2025
174ec77
undo
jnyfah Jun 18, 2025
fdc49e1
revert changes
jnyfah Jun 20, 2025
e9d080e
format
jnyfah Jun 20, 2025
ba7bdc9
Workaround missing none group support in builtin macros
Veykril Jun 27, 2025
7ddab22
Add AsMut Borrow BorrowMut to minicore and famous_defs
A4-Tacks Jun 30, 2025
6a52b3a
Migrate `replace_is_method_with_if_let_method` Assist to use `SyntaxF…
Hmikihiro Jul 1, 2025
64d3647
remove `if-let` chains
Hmikihiro Jul 1, 2025
f38da2f
Merge pull request #20134 from Hmikihiro/migrate-replace_is_method_wi…
lnicola Jul 1, 2025
61825a6
Migrate `promote_local_to_const` Assist to `SyntaxEditor`
Hmikihiro Jul 1, 2025
070b8e2
Merge pull request #20135 from Hmikihiro/migrate-promote_local_to_con…
lnicola Jul 1, 2025
aed886c
Migrate `toggle_macro_delimiter` assist to `SyntaxEditor`
Hmikihiro Jul 1, 2025
47687a4
Merge pull request #20136 from Hmikihiro/migrate-toggle_macro_delimiter
lnicola Jul 1, 2025
6f1369b
Migrate `wrap_unwrap_cfg_attr` assist to use `SyntaxEditor`
Hmikihiro Jul 1, 2025
42e9a9f
Merge pull request #20137 from Hmikihiro/migrate-wrap_unwrap_cfg_attr…
lnicola Jul 2, 2025
625b73b
Fix AsMut::as_mut name
A4-Tacks Jul 2, 2025
4cfc341
fix: Honor `rust-analyzer.cargo.noDeps` option when fetching sysroot …
ShoyuVanilla Jul 2, 2025
51ef8fb
Remove keyword prefixes (`macro@` or `macro `) from links in the docs…
ChayimFriedman2 Jul 2, 2025
c6a805c
Merge pull request #20151 from ChayimFriedman2/keyword-hover-link
Veykril Jul 3, 2025
adcb38c
Restructure proc-macro loading erros, differentiate hard error proper…
Veykril Jul 3, 2025
6dd8cfe
Merge pull request #20156 from Veykril/push-knkzxuxkzoyx
Veykril Jul 3, 2025
41c0d96
Merge pull request #20112 from Veykril/push-ruszuxrqzmvz
Veykril Jul 3, 2025
898f265
Bump salsa
Veykril Jun 4, 2025
f98e4d0
Merge pull request #19923 from Veykril/push-rlrsyxsqnxnn
Veykril Jul 3, 2025
634dd22
Re-enable fixpoint iteration for variance computation
Veykril Jul 3, 2025
60a65ec
Merge pull request #20157 from Veykril/push-nxrvpywtvoys
Veykril Jul 3, 2025
7e65c22
fix: Do not warn about proc-macro srv when sysroot is missing
Veykril Jul 3, 2025
4a6bd40
Merge pull request #20158 from Veykril/push-rquozrwuskry
Veykril Jul 3, 2025
ea88dbe
Always couple `--compile-time-deps` with
Veykril Jul 3, 2025
2a4b4ff
Merge pull request #20159 from Veykril/push-kyssnlrxlwsl
Veykril Jul 3, 2025
2899630
fix: Improve diagnostic ranges for `macro_calls!`
Veykril Jul 3, 2025
60a1359
Merge pull request #20160 from Veykril/push-pqvskktpnylu
Veykril Jul 3, 2025
9b351f1
fix: Closure capturing for let exprs, again
ShoyuVanilla Jul 3, 2025
b007ecb
fix: resolve item in match bind
Hmikihiro Jun 28, 2025
59e25a0
Merge pull request #20120 from Hmikihiro/match_bind_not_type
ChayimFriedman2 Jul 3, 2025
3ac0d56
Merge pull request #20161 from ShoyuVanilla/closure-capture
Veykril Jul 3, 2025
bbf1c9f
Migrate `unmerge_match_arm` Assist to use `SyntaxEditor`
Hmikihiro Jul 3, 2025
e045744
Fix some things with builtin derives
ChayimFriedman2 Jul 3, 2025
7a67f31
Add `fn load_workspace_into_db` variant for `ra_ap_load_cargo`'s `fn …
regexident Jul 2, 2025
a1b6621
Merge pull request #20144 from regexident/load-workspace-into-db
ChayimFriedman2 Jul 3, 2025
f34a7ec
Merge pull request #20167 from ChayimFriedman2/enum-derive-default
Veykril Jul 4, 2025
1de9e2c
Merge pull request #20165 from Hmikihiro/migrate-unmerge_match_arm
Veykril Jul 4, 2025
474e42d
Merge pull request #20148 from ShoyuVanilla/sysroot-no-deps
Veykril Jul 4, 2025
0b4cbdf
minor: Handle match arm commas in `make::match_arm`
Veykril Jul 4, 2025
b7dbf14
Merge pull request #20168 from Veykril/push-wsozylrmsyns
Veykril Jul 4, 2025
1494a27
Merge pull request #20031 from jnyfah/some-branch
Veykril Jul 4, 2025
c49987f
Skip unnecessary `eq` work in `BodySourceMap`
Veykril Jun 26, 2025
3bfe103
Merge pull request #20169 from Veykril/push-quvvsupnqqwv
Veykril Jul 4, 2025
f3325a5
Improve flycheck and build script progress reporting
Veykril Jun 26, 2025
4b506ca
Merge pull request #20170 from Veykril/push-vtsmzopsunsw
lnicola Jul 4, 2025
e779ea0
fix: Avoid .unwrap() when running the discover command
Wilfred Jun 30, 2025
babbafb
remove syntaxTree from docs
vxpm Jul 4, 2025
26fd40e
`hir_ty::match_check`: remove special handling for box patterns
dianne Jul 5, 2025
1d7fde3
Fix Borrow and BorrowMut define from beta std
A4-Tacks Jul 5, 2025
4aa30b5
Fix diverging destructuring assignments
ChayimFriedman2 Jul 5, 2025
f523843
Merge pull request #20172 from vxpm/syntax-tree-extension
ChayimFriedman2 Jul 5, 2025
7fb07c9
Merge pull request #20175 from dianne/match-check-box-cleanup
ChayimFriedman2 Jul 6, 2025
bc10a25
Merge pull request #20179 from ChayimFriedman2/destructuring-assignme…
Veykril Jul 6, 2025
37f2263
Merge pull request #20126 from Wilfred/no_unwrap_in_discover_projects
Veykril Jul 6, 2025
eca5905
Merge pull request #20132 from A4-Tacks/asmut-borrow-minicore
Veykril Jul 6, 2025
836e0cb
chore: Remove dead field from `InferenceContext`
Veykril Jul 6, 2025
1cf9a7b
Merge pull request #20184 from Veykril/push-ywpynxnltpok
Veykril Jul 6, 2025
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
52 changes: 38 additions & 14 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,6 @@ dependencies = [
"hashbrown 0.15.4",
]

[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"

[[package]]
name = "hermit-abi"
version = "0.5.2"
Expand Down Expand Up @@ -1020,6 +1014,15 @@ dependencies = [
"triomphe",
]

[[package]]
name = "intrusive-collections"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "189d0897e4cbe8c75efedf3502c18c887b05046e59d28404d4d8e46cbc4d1e86"
dependencies = [
"memoffset",
]

[[package]]
name = "itertools"
version = "0.12.1"
Expand Down Expand Up @@ -1427,6 +1430,16 @@ dependencies = [
"num-traits",
]

[[package]]
name = "papaya"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f92dd0b07c53a0a0c764db2ace8c541dc47320dad97c2200c2a637ab9dd2328f"
dependencies = [
"equivalent",
"seize",
]

[[package]]
name = "parking_lot"
version = "0.12.4"
Expand Down Expand Up @@ -1955,16 +1968,18 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"

[[package]]
name = "salsa"
version = "0.22.0"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8fff508e3d6ef42a32607f7538e17171a877a12015e32036f46e99d00c95781"
checksum = "2e235afdb8e510f38a07138fbe5a0b64691894358a9c0cbd813b1aade110efc9"
dependencies = [
"boxcar",
"crossbeam-queue",
"dashmap",
"crossbeam-utils",
"hashbrown 0.15.4",
"hashlink",
"indexmap",
"intrusive-collections",
"papaya",
"parking_lot",
"portable-atomic",
"rayon",
Expand All @@ -1978,17 +1993,16 @@ dependencies = [

[[package]]
name = "salsa-macro-rules"
version = "0.22.0"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea72b3c06f2ce6350fe3a0eeb7aaaf842d1d8352b706973c19c4f02e298a87c"
checksum = "2edb86a7e9c91f6d30c9ce054312721dbe773a162db27bbfae834d16177b30ce"

[[package]]
name = "salsa-macros"
version = "0.22.0"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce92025bc160b27814a207cb78d680973af17f863c7f4fc56cf3a535e22f378"
checksum = "d0778d6e209051bc4e75acfe83bcd7848601ec3dbe9c3dbb982829020e9128af"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
Expand Down Expand Up @@ -2025,6 +2039,16 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"

[[package]]
name = "seize"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4b8d813387d566f627f3ea1b914c068aac94c40ae27ec43f5f33bde65abefe7"
dependencies = [
"libc",
"windows-sys 0.52.0",
]

[[package]]
name = "semver"
version = "1.0.26"
Expand Down
6 changes: 4 additions & 2 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ debug = 2
# ungrammar = { path = "../ungrammar" }

# salsa = { path = "../salsa" }
# salsa-macros = { path = "../salsa/components/salsa-macros" }
# salsa-macro-rules = { path = "../salsa/components/salsa-macro-rules" }

[workspace.dependencies]
# local crates
Expand Down Expand Up @@ -136,8 +138,8 @@ rayon = "1.10.0"
rowan = "=0.15.15"
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
# on impls without it
salsa = { version = "0.22.0", default-features = true, features = ["rayon","salsa_unstable", "macros"] }
salsa-macros = "0.22.0"
salsa = { version = "0.23.0", default-features = true, features = ["rayon","salsa_unstable", "macros"] }
salsa-macros = "0.23.0"
semver = "1.0.26"
serde = { version = "1.0.219" }
serde_derive = { version = "1.0.219" }
Expand Down
45 changes: 44 additions & 1 deletion src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
//! actual IO is done and lowered to input.

use std::error::Error;
use std::hash::BuildHasherDefault;
use std::{fmt, mem, ops};

Expand All @@ -22,7 +23,49 @@ use vfs::{AbsPathBuf, AnchoredPath, FileId, VfsPath, file_set::FileSet};

use crate::{CrateWorkspaceData, EditionedFileId, FxIndexSet, RootQueryDb};

pub type ProcMacroPaths = FxHashMap<CrateBuilderId, Result<(String, AbsPathBuf), String>>;
pub type ProcMacroPaths =
FxHashMap<CrateBuilderId, Result<(String, AbsPathBuf), ProcMacroLoadingError>>;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProcMacroLoadingError {
Disabled,
FailedToBuild,
MissingDylibPath,
NotYetBuilt,
NoProcMacros,
ProcMacroSrvError(Box<str>),
}
impl ProcMacroLoadingError {
pub fn is_hard_error(&self) -> bool {
match self {
ProcMacroLoadingError::Disabled | ProcMacroLoadingError::NotYetBuilt => false,
ProcMacroLoadingError::FailedToBuild
| ProcMacroLoadingError::MissingDylibPath
| ProcMacroLoadingError::NoProcMacros
| ProcMacroLoadingError::ProcMacroSrvError(_) => true,
}
}
}

impl Error for ProcMacroLoadingError {}
impl fmt::Display for ProcMacroLoadingError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ProcMacroLoadingError::Disabled => write!(f, "proc-macro expansion is disabled"),
ProcMacroLoadingError::FailedToBuild => write!(f, "proc-macro failed to build"),
ProcMacroLoadingError::MissingDylibPath => {
write!(f, "proc-macro crate build data is missing a dylib path")
}
ProcMacroLoadingError::NotYetBuilt => write!(f, "proc-macro not yet built"),
ProcMacroLoadingError::NoProcMacros => {
write!(f, "proc macro library has no proc macros")
}
ProcMacroLoadingError::ProcMacroSrvError(msg) => {
write!(f, "proc macro server error: {msg}")
}
}
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SourceRootId(pub u32);
Expand Down
11 changes: 6 additions & 5 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ pub use crate::{
input::{
BuiltCrateData, BuiltDependency, Crate, CrateBuilder, CrateBuilderId, CrateDataBuilder,
CrateDisplayName, CrateGraphBuilder, CrateName, CrateOrigin, CratesIdMap, CratesMap,
DependencyBuilder, Env, ExtraCrateData, LangCrateOrigin, ProcMacroPaths, ReleaseChannel,
SourceRoot, SourceRootId, TargetLayoutLoadResult, UniqueCrateData,
DependencyBuilder, Env, ExtraCrateData, LangCrateOrigin, ProcMacroLoadingError,
ProcMacroPaths, ReleaseChannel, SourceRoot, SourceRootId, TargetLayoutLoadResult,
UniqueCrateData,
},
};
use dashmap::{DashMap, mapref::entry::Entry};
Expand All @@ -33,7 +34,7 @@ pub type FxIndexSet<T> = indexmap::IndexSet<T, rustc_hash::FxBuildHasher>;
#[macro_export]
macro_rules! impl_intern_key {
($id:ident, $loc:ident) => {
#[salsa_macros::interned(no_lifetime)]
#[salsa_macros::interned(no_lifetime, revisions = usize::MAX)]
#[derive(PartialOrd, Ord)]
pub struct $id {
pub loc: $loc,
Expand All @@ -43,7 +44,7 @@ macro_rules! impl_intern_key {
impl ::std::fmt::Debug for $id {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.debug_tuple(stringify!($id))
.field(&format_args!("{:04x}", self.0.as_u32()))
.field(&format_args!("{:04x}", self.0.index()))
.finish()
}
}
Expand Down Expand Up @@ -167,7 +168,7 @@ impl Files {
}
}

#[salsa_macros::interned(no_lifetime, debug, constructor=from_span)]
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span, revisions = usize::MAX)]
#[derive(PartialOrd, Ord)]
pub struct EditionedFileId {
pub editioned_file_id: span::EditionedFileId,
Expand Down
58 changes: 48 additions & 10 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub type TypeSource = InFile<TypePtr>;
pub type LifetimePtr = AstPtr<ast::Lifetime>;
pub type LifetimeSource = InFile<LifetimePtr>;

#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct ExpressionStore {
pub exprs: Arena<Expr>,
pub pats: Arena<Pat>,
Expand All @@ -114,7 +114,7 @@ pub struct ExpressionStore {
ident_hygiene: FxHashMap<ExprOrPatId, HygieneId>,
}

#[derive(Debug, Eq, PartialEq, Default)]
#[derive(Debug, Eq, Default)]
pub struct ExpressionStoreSourceMap {
// AST expressions can create patterns in destructuring assignments. Therefore, `ExprSource` can also map
// to `PatId`, and `PatId` can also map to `ExprSource` (the other way around is unaffected).
Expand All @@ -127,19 +127,20 @@ pub struct ExpressionStoreSourceMap {
label_map: FxHashMap<LabelSource, LabelId>,
label_map_back: ArenaMap<LabelId, LabelSource>,

binding_definitions: FxHashMap<BindingId, SmallVec<[PatId; 4]>>,

/// We don't create explicit nodes for record fields (`S { record_field: 92 }`).
/// Instead, we use id of expression (`92`) to identify the field.
field_map_back: FxHashMap<ExprId, FieldSource>,
pat_field_map_back: FxHashMap<PatId, PatFieldSource>,

types_map_back: ArenaMap<TypeRefId, TypeSource>,
types_map: FxHashMap<TypeSource, TypeRefId>,

lifetime_map_back: ArenaMap<LifetimeRefId, LifetimeSource>,
lifetime_map: FxHashMap<LifetimeSource, LifetimeRefId>,

binding_definitions:
ArenaMap<BindingId, SmallVec<[PatId; 2 * size_of::<usize>() / size_of::<PatId>()]>>,

/// We don't create explicit nodes for record fields (`S { record_field: 92 }`).
/// Instead, we use id of expression (`92`) to identify the field.
field_map_back: FxHashMap<ExprId, FieldSource>,
pat_field_map_back: FxHashMap<PatId, PatFieldSource>,

template_map: Option<Box<FormatTemplate>>,

pub expansions: FxHashMap<InFile<MacroCallPtr>, MacroCallId>,
Expand All @@ -149,6 +150,43 @@ pub struct ExpressionStoreSourceMap {
pub diagnostics: Vec<ExpressionStoreDiagnostics>,
}

impl PartialEq for ExpressionStoreSourceMap {
fn eq(&self, other: &Self) -> bool {
// we only need to compare one of the two mappings
// as the other is a reverse mapping and thus will compare
// the same as normal mapping
let Self {
expr_map: _,
expr_map_back,
pat_map: _,
pat_map_back,
label_map: _,
label_map_back,
types_map_back,
types_map: _,
lifetime_map_back,
lifetime_map: _,
// If this changed, our pattern data must have changed
binding_definitions: _,
// If this changed, our expression data must have changed
field_map_back: _,
// If this changed, our pattern data must have changed
pat_field_map_back: _,
template_map,
expansions,
diagnostics,
} = self;
*expr_map_back == other.expr_map_back
&& *pat_map_back == other.pat_map_back
&& *label_map_back == other.label_map_back
&& *types_map_back == other.types_map_back
&& *lifetime_map_back == other.lifetime_map_back
&& *template_map == other.template_map
&& *expansions == other.expansions
&& *diagnostics == other.diagnostics
}
}

/// The body of an item (function, const etc.).
#[derive(Debug, Eq, PartialEq, Default)]
pub struct ExpressionStoreBuilder {
Expand Down Expand Up @@ -698,7 +736,7 @@ impl ExpressionStoreSourceMap {
}

pub fn patterns_for_binding(&self, binding: BindingId) -> &[PatId] {
self.binding_definitions.get(&binding).map_or(&[], Deref::deref)
self.binding_definitions.get(binding).map_or(&[], Deref::deref)
}

pub fn node_label(&self, node: InFile<&ast::Label>) -> Option<LabelId> {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub enum Path {
// This type is being used a lot, make sure it doesn't grow unintentionally.
#[cfg(target_arch = "x86_64")]
const _: () = {
assert!(size_of::<Path>() == 16);
assert!(size_of::<Option<Path>>() == 16);
assert!(size_of::<Path>() == 24);
assert!(size_of::<Option<Path>>() == 24);
};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ fn foo() {

let resolved = scopes.resolve_name_in_scope(expr_scope, &name_ref.as_name()).unwrap();
let pat_src = source_map
.pat_syntax(*source_map.binding_definitions[&resolved.binding()].first().unwrap())
.pat_syntax(*source_map.binding_definitions[resolved.binding()].first().unwrap())
.unwrap();

let local_name = pat_src.value.syntax_node_ptr().to_node(file.syntax());
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/hir/type_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub enum TypeRef {
}

#[cfg(target_arch = "x86_64")]
const _: () = assert!(size_of::<TypeRef>() == 16);
const _: () = assert!(size_of::<TypeRef>() == 24);

pub type TypeRefId = Idx<TypeRef>;

Expand Down
Loading
Loading