Skip to content
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

internal: port rust-analyzer to new Salsa #18964

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
05485da
internal: port basedb to new salsa
davidbarsky Nov 5, 2024
5e8dea5
internal: point salsa against personal fork
davidbarsky Nov 14, 2024
959a674
span: qualify `ra_salsa` imports
davidbarsky Nov 21, 2024
b22420f
internal: port hir-expand to new salsa
davidbarsky Nov 26, 2024
270e46e
internal: port hir-def to new salsa
davidbarsky Dec 6, 2024
451845e
internal: ensure new salsa works in ra
davidbarsky Dec 12, 2024
720bcbf
internal: reintroduce file_source_root
davidbarsky Dec 14, 2024
f8016f3
internal: port `SyntaxContext`; macro expansion to new salsa.
Veykril Dec 16, 2024
f57f275
internal: update test snapshots, remove `dbg!`, fix warnings
davidbarsky Dec 17, 2024
e3cae00
internal: mutate file inputs; allowing editing
davidbarsky Dec 24, 2024
42c7f3b
internal: fix conflicts/issues; deduplicate some SourceRootDb queries
Veykril Dec 24, 2024
a90ad0e
fix: ensure that all `SourceDatabase` implementations mutate inputs
davidbarsky Jan 1, 2025
f7b1464
use `Database::unwind_if_revision_cancelled`
davidbarsky Jan 6, 2025
d377785
support per-edition tokens
davidbarsky Jan 6, 2025
17ced9c
cleanup SyntaxContext
davidbarsky Jan 9, 2025
2483029
Intern FileId/EditionedFileId into a Salsa struct
davidbarsky Jan 10, 2025
4eef0f5
update salsa fork
davidbarsky Jan 15, 2025
14802da
tune LRU capacities
davidbarsky Jan 16, 2025
18f1146
enums
ChayimFriedman2 Jan 5, 2025
75e087b
fix cargo.toml stuff
davidbarsky Jan 20, 2025
1300dce
fix warnings
davidbarsky Jan 20, 2025
f2f811a
allow unicode licenses
davidbarsky Jan 20, 2025
54ef4ea
update rust-analyzer to new interned struct
davidbarsky Jan 23, 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
939 changes: 711 additions & 228 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = ["rust-analyzer team"]
repository = "https://github.com/rust-lang/rust-analyzer"

[profile.dev]
debug = 1
debug = 2

[profile.dev.package]
# These speed up local tests.
Expand All @@ -27,7 +27,7 @@ miniz_oxide.opt-level = 3
[profile.release]
incremental = true
# Set this to 1 or 2 to get more useful backtraces in debugger.
debug = 0
debug = 2

[profile.dev-rel]
inherits = "release"
Expand Down Expand Up @@ -74,7 +74,6 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
profile = { path = "./crates/profile", version = "0.0.0" }
project-model = { path = "./crates/project-model", version = "0.0.0" }
ra-salsa = { path = "./crates/ra-salsa", package = "salsa", version = "0.0.0" }
span = { path = "./crates/span", version = "0.0.0" }
stdx = { path = "./crates/stdx", version = "0.0.0" }
syntax = { path = "./crates/syntax", version = "0.0.0" }
Expand Down Expand Up @@ -136,6 +135,8 @@ process-wrap = { version = "8.0.2", features = ["std"] }
pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.0", default-features = false }
rayon = "1.8.0"
salsa = { git = "https://github.com/davidbarsky/salsa.git", branch = "chayim-david-lukas/salsa-changes-for-ra" }
db-ext-macro = { git = "https://github.com/davidbarsky/db-ext-macro.git", rev = "c88f2f058ac4e6a8a09e87e41d7b30b147235514" }
rustc-hash = "2.0.0"
semver = "1.0.14"
serde = { version = "1.0.192" }
Expand Down
4 changes: 3 additions & 1 deletion crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ doctest = false
lz4_flex = { version = "0.11", default-features = false }

la-arena.workspace = true
ra-salsa.workspace = true
dashmap.workspace = true
salsa.workspace = true
db-ext-macro.workspace = true
rustc-hash.workspace = true
triomphe.workspace = true
semver.workspace = true
Expand Down
15 changes: 7 additions & 8 deletions crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

use std::fmt;

use ra_salsa::Durability;
use rustc_hash::FxHashMap;
use salsa::Durability;
use triomphe::Arc;
use vfs::FileId;

use crate::{
CrateGraph, CrateId, CrateWorkspaceData, SourceDatabaseFileInputExt, SourceRoot,
SourceRootDatabase, SourceRootId,
};
use crate::{CrateGraph, CrateId, CrateWorkspaceData, RootQueryDb, SourceRoot, SourceRootId};

/// Encapsulate a bunch of raw `.set` calls on the database.
#[derive(Default)]
Expand Down Expand Up @@ -59,7 +56,7 @@ impl FileChange {
self.ws_data = Some(data);
}

pub fn apply(self, db: &mut dyn SourceRootDatabase) {
pub fn apply(self, db: &mut dyn RootQueryDb) {
let _p = tracing::info_span!("FileChange::apply").entered();
if let Some(roots) = self.roots {
for (idx, root) in roots.into_iter().enumerate() {
Expand All @@ -68,14 +65,16 @@ impl FileChange {
for file_id in root.iter() {
db.set_file_source_root_with_durability(file_id, root_id, durability);
}

db.set_source_root_with_durability(root_id, Arc::new(root), durability);
}
}

for (file_id, text) in self.files_changed {
let source_root_id = db.file_source_root(file_id);
let source_root = db.source_root(source_root_id);
let durability = durability(&source_root);
let source_root = db.source_root(source_root_id.source_root_id(db));

let durability = durability(&source_root.source_root(db));
// XXX: can't actually remove the file, just reset the text
let text = text.unwrap_or_default();
db.set_file_text_with_durability(file_id, &text, durability)
Expand Down
Loading
Loading