Skip to content

Subtree update of rust-analyzer #140651

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 56 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a3c5b6a
Fix span info for mir::Operand
alibektas Feb 27, 2025
d2de4c9
change test name to sth meaningful
alibektas Feb 28, 2025
593775a
Add PGO support to install
fbernier Apr 18, 2025
2b701e0
Escape raw names in labels properly
ChayimFriedman2 Apr 26, 2025
8118676
Don't escape `'static`
ChayimFriedman2 Apr 26, 2025
7e064c3
Add expression fill mode variant for filling with underscore expressions
Veykril Apr 28, 2025
bb906cc
Merge pull request #19704 from Veykril/push-wrvznvvpvtvp
Veykril Apr 28, 2025
99f0092
fix: Address minor FIXME
Veykril Apr 28, 2025
62a48c5
Merge pull request #19706 from Veykril/push-nkpmknlvzyom
Veykril Apr 28, 2025
2231efa
refactor: migrate `let_else_to_match` to editor
snprajwal Apr 8, 2025
1b3374f
fix: migrate `unmerge_use` to syntax editor
snprajwal Mar 27, 2025
30eeab0
chore: rename `unmerge_use` to `unmerge_imports`
snprajwal Mar 28, 2025
32bf2ac
refactor: migrate `merge_imports` to syntax editor
snprajwal Mar 28, 2025
f479012
refactor: De-arc lang item queries
Veykril Apr 28, 2025
d2ec47e
Merge pull request #19469 from snprajwal/merge-imports
Veykril Apr 28, 2025
a839a66
Merge pull request #19542 from snprajwal/let-else-to-match
Veykril Apr 28, 2025
746c689
Merge pull request #19708 from Veykril/push-wrmyowrzkxzz
Veykril Apr 28, 2025
833f526
base-db: add more details to panic
davidbarsky Apr 28, 2025
b602274
Merge pull request #19710 from rust-lang/davidbarsky/add-additional-d…
ChayimFriedman2 Apr 28, 2025
0b02aed
Merge pull request #19699 from ChayimFriedman2/escape-label
davidbarsky Apr 28, 2025
d93d553
refactor: Clean up cache priming cancellation handling
Veykril Apr 29, 2025
8183c65
Merge pull request #19712 from Veykril/push-yzsxpmkytkzt
Veykril Apr 29, 2025
97f0f68
Cleanup cfg check handling in expression store lowering
Veykril Apr 29, 2025
bae7322
Merge pull request #19685 from fbernier/pgo-install
Veykril Apr 29, 2025
df4b8f3
Merge pull request #19713 from Veykril/push-xkppskpmuzpo
Veykril Apr 29, 2025
21e7003
refactor: Remove unnecessary extension trait
Veykril Apr 29, 2025
85ab1d2
Merge pull request #19714 from Veykril/push-owpqqzqmrpvv
Veykril Apr 29, 2025
0e139b8
Update salsa
Veykril Apr 29, 2025
3f92794
Split out salsa_macros
Veykril Apr 29, 2025
fedec9b
Merge pull request #19716 from Veykril/push-wmmvswskoktw
Veykril Apr 29, 2025
1b677ce
chore: Adjust panic context printing
Veykril Apr 30, 2025
624572e
Merge pull request #19719 from Veykril/push-nuwnnztxrzyv
Veykril Apr 30, 2025
1306a5a
Merge pull request #19247 from alibektas/19172_very_new
Veykril Apr 30, 2025
09188e6
fix: Improve parser recovery a bit
Veykril Apr 30, 2025
97bdf14
Merge pull request #19723 from Veykril/push-skswknpxtzlz
Veykril Apr 30, 2025
a6b8abf
Bump salsa
Veykril May 1, 2025
e750221
Merge pull request #19725 from Veykril/push-xwqzzsklslrq
Veykril May 1, 2025
408232f
Update lockfile
lnicola May 1, 2025
b01b98f
Preparing for merge from rust-lang/rust
lnicola May 1, 2025
1c5de64
Merge from rust-lang/rust
lnicola May 1, 2025
00d2f60
Merge pull request #19726 from lnicola/sync-from-rust
lnicola May 1, 2025
3e196c0
remove a couple of clones
matthiaskrgr May 1, 2025
c45126e
Merge pull request #19727 from matthiaskrgr/enolc
lnicola May 1, 2025
f20e853
Render more lifetimes
Veykril Apr 14, 2025
3686ed9
Merge pull request #19581 from Veykril/push-uvyutolsqnun
Veykril May 2, 2025
a8fb9d0
refactor: Simplify macro call id construction
Veykril May 2, 2025
9eb1e83
fix: Correct assoc ty bound var starting index
ShoyuVanilla May 2, 2025
372f3f3
Merge pull request #19731 from Veykril/push-mmvowomkpwxy
Veykril May 2, 2025
d8a52db
fix: Implement mut to const ptr cast for method resolution
ShoyuVanilla May 2, 2025
4e3bdb9
Merge pull request #19732 from ShoyuVanilla/issue-19730
Veykril May 2, 2025
429027a
Merge pull request #19733 from ShoyuVanilla/issue-19724
Veykril May 2, 2025
1327f70
Improve the let code snippet
A4-Tacks May 3, 2025
7768602
Improve let snippet
A4-Tacks May 3, 2025
58ef378
Merge pull request #19735 from A4-Tacks/improve-let-snippet
Veykril May 4, 2025
d6183aa
Disable fixpoint for variance computation temporarily
Veykril May 4, 2025
8f3bb8b
Merge pull request #19739 from Veykril/push-kpozprqnsmkk
Veykril May 4, 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
18 changes: 12 additions & 6 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ dependencies = [
"query-group-macro",
"rustc-hash 2.1.1",
"salsa",
"salsa-macros",
"semver",
"span",
"syntax",
Expand Down Expand Up @@ -630,6 +631,7 @@ dependencies = [
"rustc-hash 2.1.1",
"rustc_apfloat",
"salsa",
"salsa-macros",
"smallvec",
"span",
"stdx",
Expand Down Expand Up @@ -660,6 +662,7 @@ dependencies = [
"query-group-macro",
"rustc-hash 2.1.1",
"salsa",
"salsa-macros",
"smallvec",
"span",
"stdx",
Expand Down Expand Up @@ -700,6 +703,7 @@ dependencies = [
"rustc-hash 2.1.1",
"rustc_apfloat",
"salsa",
"salsa-macros",
"scoped-tls",
"smallvec",
"span",
Expand Down Expand Up @@ -936,6 +940,7 @@ dependencies = [
"rayon",
"rustc-hash 2.1.1",
"salsa",
"salsa-macros",
"span",
"stdx",
"syntax",
Expand Down Expand Up @@ -1729,6 +1734,7 @@ dependencies = [
"proc-macro2",
"quote",
"salsa",
"salsa-macros",
"syn",
]

Expand Down Expand Up @@ -2033,9 +2039,9 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"

[[package]]
name = "salsa"
version = "0.20.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1be22155f8d9732518b2db2bf379fe6f0b2375e76b08b7c8fe6c1b887d548c24"
checksum = "6f80d5cf3c3fcab2cef898012f242a670477a1baa609267376af9cb4409026c5"
dependencies = [
"boxcar",
"crossbeam-queue",
Expand All @@ -2056,15 +2062,15 @@ dependencies = [

[[package]]
name = "salsa-macro-rules"
version = "0.20.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f55a7ef0a84e336f7c5f0332d81727f5629fe042d2aa556c75307afebc9f78a5"
checksum = "05303d72606fbf2b9c9523cda2039bb8ecb00304027a3cd7e52b02a65c7d9185"

[[package]]
name = "salsa-macros"
version = "0.20.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d0e88a9c0c0d231a63f83dcd1a2c5e5d11044fac4b65bc9ad3b68ab48b0a0ab"
checksum = "eb2f0e2a30c65cb3cd63440c491dde68d9af7e1be2b77832ac7057141107db50"
dependencies = [
"heck",
"proc-macro2",
Expand Down
4 changes: 3 additions & 1 deletion src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ process-wrap = { version = "8.2.0", features = ["std"] }
pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.6", default-features = false }
rayon = "1.10.0"
salsa = "0.20.0"
rowan = "=0.15.15"
salsa = { version = "0.21.1", default-features = false, features = ["rayon","salsa_unstable"] }
salsa-macros = "0.21.1"
semver = "1.0.26"
serde = { version = "1.0.219" }
serde_derive = { version = "1.0.219" }
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rust-version.workspace = true
la-arena.workspace = true
dashmap.workspace = true
salsa.workspace = true
salsa-macros.workspace = true
query-group.workspace = true
rustc-hash.workspace = true
triomphe.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl BuiltDependency {

pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;

#[salsa::input]
#[salsa_macros::input]
#[derive(Debug)]
pub struct Crate {
#[return_ref]
Expand Down
94 changes: 76 additions & 18 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//! base_db defines basic database traits. The concrete DB is defined by ide.

pub use salsa;
pub use salsa_macros;

// FIXME: Rename this crate, base db is non descriptive
mod change;
mod input;

use std::hash::BuildHasherDefault;
use std::{cell::RefCell, hash::BuildHasherDefault, panic, sync::Once};

pub use crate::{
change::FileChange,
Expand All @@ -17,7 +21,6 @@ pub use crate::{
use dashmap::{DashMap, mapref::entry::Entry};
pub use query_group::{self};
use rustc_hash::{FxHashSet, FxHasher};
pub use salsa::{self};
use salsa::{Durability, Setter};
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
use span::Edition;
Expand All @@ -28,7 +31,7 @@ pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet}
#[macro_export]
macro_rules! impl_intern_key {
($id:ident, $loc:ident) => {
#[salsa::interned(no_lifetime)]
#[salsa_macros::interned(no_lifetime)]
pub struct $id {
pub loc: $loc,
}
Expand Down Expand Up @@ -57,7 +60,12 @@ pub struct Files {

impl Files {
pub fn file_text(&self, file_id: vfs::FileId) -> FileText {
*self.files.get(&file_id).expect("Unable to fetch file; this is a bug")
match self.files.get(&file_id) {
Some(text) => *text,
None => {
panic!("Unable to fetch file text for `vfs::FileId`: {file_id:?}; this is a bug")
}
}
}

pub fn set_file_text(&self, db: &mut dyn SourceDatabase, file_id: vfs::FileId, text: &str) {
Expand Down Expand Up @@ -93,10 +101,12 @@ impl Files {

/// Source root of the file.
pub fn source_root(&self, source_root_id: SourceRootId) -> SourceRootInput {
let source_root = self
.source_roots
.get(&source_root_id)
.expect("Unable to fetch source root id; this is a bug");
let source_root = match self.source_roots.get(&source_root_id) {
Some(source_root) => source_root,
None => panic!(
"Unable to fetch `SourceRootInput` with `SourceRootId` ({source_root_id:?}); this is a bug"
),
};

*source_root
}
Expand All @@ -121,10 +131,12 @@ impl Files {
}

pub fn file_source_root(&self, id: vfs::FileId) -> FileSourceRootInput {
let file_source_root = self
.file_source_roots
.get(&id)
.expect("Unable to fetch FileSourceRootInput; this is a bug");
let file_source_root = match self.file_source_roots.get(&id) {
Some(file_source_root) => file_source_root,
None => panic!(
"Unable to get `FileSourceRootInput` with `vfs::FileId` ({id:?}); this is a bug",
),
};
*file_source_root
}

Expand Down Expand Up @@ -152,7 +164,7 @@ impl Files {
}
}

#[salsa::interned(no_lifetime, debug, constructor=from_span)]
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span)]
pub struct EditionedFileId {
pub editioned_file_id: span::EditionedFileId,
}
Expand Down Expand Up @@ -187,18 +199,18 @@ impl EditionedFileId {
}
}

#[salsa::input(debug)]
#[salsa_macros::input(debug)]
pub struct FileText {
pub text: Arc<str>,
pub file_id: vfs::FileId,
}

#[salsa::input(debug)]
#[salsa_macros::input(debug)]
pub struct FileSourceRootInput {
pub source_root_id: SourceRootId,
}

#[salsa::input(debug)]
#[salsa_macros::input(debug)]
pub struct SourceRootInput {
pub source_root: Arc<SourceRoot>,
}
Expand Down Expand Up @@ -265,7 +277,7 @@ pub fn transitive_deps(db: &dyn SourceDatabase, crate_id: Crate) -> FxHashSet<Cr
deps
}

#[salsa::db]
#[salsa_macros::db]
pub trait SourceDatabase: salsa::Database {
/// Text of the file.
fn file_text(&self, file_id: vfs::FileId) -> FileText;
Expand Down Expand Up @@ -344,7 +356,7 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
}

fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<&[SyntaxError]> {
#[salsa::tracked(return_ref)]
#[salsa_macros::tracked(return_ref)]
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<Box<[SyntaxError]>> {
let errors = db.parse(file_id).errors();
match &*errors {
Expand Down Expand Up @@ -373,3 +385,49 @@ fn relevant_crates(db: &dyn RootQueryDb, file_id: FileId) -> Arc<[Crate]> {
let source_root = db.file_source_root(file_id);
db.source_root_crates(source_root.source_root_id(db))
}

#[must_use]
#[non_exhaustive]
pub struct DbPanicContext;

impl Drop for DbPanicContext {
fn drop(&mut self) {
Self::with_ctx(|ctx| assert!(ctx.pop().is_some()));
}
}

impl DbPanicContext {
pub fn enter(frame: String) -> DbPanicContext {
#[expect(clippy::print_stderr, reason = "already panicking anyway")]
fn set_hook() {
let default_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| {
default_hook(panic_info);
if let Some(backtrace) = salsa::Backtrace::capture() {
eprintln!("{backtrace:#}");
}
DbPanicContext::with_ctx(|ctx| {
if !ctx.is_empty() {
eprintln!("additional context:");
for (idx, frame) in ctx.iter().enumerate() {
eprintln!("{idx:>4}: {frame}\n");
}
}
});
}));
}

static SET_HOOK: Once = Once::new();
SET_HOOK.call_once(set_hook);

Self::with_ctx(|ctx| ctx.push(frame));
DbPanicContext
}

fn with_ctx(f: impl FnOnce(&mut Vec<String>)) {
thread_local! {
static CTX: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) };
}
CTX.with(|ctx| f(&mut ctx.borrow_mut()));
}
}
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ triomphe.workspace = true
rustc_apfloat = "0.2.2"
text-size.workspace = true
salsa.workspace = true
salsa-macros.workspace = true
query-group.workspace = true

ra-ap-rustc_parse_format.workspace = true
Expand Down
Loading
Loading