Skip to content

Commit ed456fd

Browse files
committed
chore: update salsa to the latest version
Well, previous salsa version has a [serious bug](salsa-rs/salsa#473) which makes lsp deadlock from time to time, I've fixed it in April, but somehow forget to update salsa orz.
1 parent 615d95f commit ed456fd

23 files changed

+956
-791
lines changed

Cargo.lock

+447-304
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ lsp-server = "0.7"
4141
serde_json = "1.0"
4242
rustc-hash = "1.1"
4343
crossbeam-channel = "0.5"
44-
salsa = { package = "salsa-2022", git = "https://github.com/salsa-rs/salsa", rev = "4151b09d3c37e50f1a01894fcdfa776bc2909132" }
44+
salsa = { package = "salsa", git = "https://github.com/salsa-rs/salsa", branch = "master" }
4545
enum_dispatch = "0.3"
4646
threadpool = { version = "1.8", optional = true }
4747
dunce = "1.0"

src/ast/accumulators.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ use lsp_types::{
88
use super::diag::PLDiag;
99

1010
#[salsa::accumulator]
11-
pub struct Diagnostics((String, Vec<PLDiag>));
11+
pub struct Diagnostics(pub (String, Vec<PLDiag>));
1212

1313
#[salsa::accumulator]
14-
pub struct PLReferences(Vec<Location>);
14+
pub struct PLReferences(pub Vec<Location>);
1515

1616
#[salsa::accumulator]
17-
pub struct GotoDef(GotoDefinitionResponse);
17+
pub struct GotoDef(pub GotoDefinitionResponse);
1818

1919
#[salsa::accumulator]
20-
pub struct Completions(Vec<CompletionItem>);
20+
pub struct Completions(pub Vec<CompletionItem>);
2121

2222
#[salsa::accumulator]
23-
pub struct PLSemanticTokens(SemanticTokens);
23+
pub struct PLSemanticTokens(pub SemanticTokens);
2424

2525
#[salsa::accumulator]
26-
pub struct PLCodeLens(CodeLens);
26+
pub struct PLCodeLens(pub CodeLens);
2727

2828
#[salsa::accumulator]
29-
pub struct PLHover(Hover);
29+
pub struct PLHover(pub Hover);
3030

3131
#[salsa::accumulator]
32-
pub struct ModBuffer(PLModBuffer);
32+
pub struct ModBuffer(pub PLModBuffer);
3333

3434
#[derive(Debug, Clone)]
3535
pub struct PLModBuffer {
@@ -40,11 +40,11 @@ pub struct PLModBuffer {
4040
}
4141

4242
#[salsa::accumulator]
43-
pub struct PLFormat(Vec<TextEdit>);
43+
pub struct PLFormat(pub Vec<TextEdit>);
4444
#[salsa::accumulator]
45-
pub struct Hints(Vec<InlayHint>);
45+
pub struct Hints(pub Vec<InlayHint>);
4646
#[salsa::accumulator]
47-
pub struct DocSymbols(Vec<DocumentSymbol>);
47+
pub struct DocSymbols(pub Vec<DocumentSymbol>);
4848

4949
#[salsa::accumulator]
50-
pub struct PLSignatureHelp(SignatureHelp);
50+
pub struct PLSignatureHelp(pub SignatureHelp);

src/ast/builder/llvmbuilder.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -2040,12 +2040,13 @@ impl<'a, 'ctx> IRBuilder<'a, 'ctx> for LLVMBuilder<'a, 'ctx> {
20402040
Err(format!("{:?}\ntp: {:?}\nindex: {}", gep, tp, index))
20412041
}
20422042
}
2043-
fn place_safepoint(&self, ctx: &mut Ctx<'a>) {
2044-
let f = self.get_gc_mod_f(ctx, "DioGC__safepoint");
2045-
let rsp = self.get_sp();
2046-
self.builder
2047-
.build_call(f, &[rsp.into()], "safepoint")
2048-
.unwrap();
2043+
fn place_safepoint(&self, _ctx: &mut Ctx<'a>) {
2044+
// FIXME
2045+
// let f = self.get_gc_mod_f(ctx, "DioGC__safepoint");
2046+
// let rsp = self.get_sp();
2047+
// self.builder
2048+
// .build_call(f, &[rsp.into()], "safepoint")
2049+
// .unwrap();
20492050
}
20502051
fn build_store(&self, ptr: ValueHandle, value: ValueHandle) {
20512052
let ptr = self.get_llvm_value(ptr).unwrap();

src/ast/compiler.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn compile(db: &dyn Db, docs: MemDocsInput, out: String, op: Options) {
115115
/// compile_dry compiles the source code of pivot-lang into the pivot-lang AST with a wrapper.
116116
/// the `dry` refers the function ends up parsing at LLVM IR or LSP analysis.
117117
#[salsa::tracked]
118-
pub fn compile_dry(db: &dyn Db, docs: MemDocsInput) -> Result<ModWrapper, String> {
118+
pub fn compile_dry<'db>(db: &'db dyn Db, docs: MemDocsInput) -> Result<ModWrapper<'db>, String> {
119119
let path = search_config_file(docs.file(db).to_string());
120120
if path.is_err() {
121121
log::warn!("lsp error: {}", path.err().unwrap());
@@ -148,7 +148,10 @@ pub fn compile_dry(db: &dyn Db, docs: MemDocsInput) -> Result<ModWrapper, String
148148
/// compile_dry_file parses the file inside parser_entry into AST,
149149
/// and then emit the llvm IR code represented by Mod according to the entry file AST.
150150
#[salsa::tracked(recovery_fn=cycle_deps_recover)]
151-
pub fn compile_dry_file(db: &dyn Db, parser_entry: FileCompileInput) -> Option<ModWrapper> {
151+
pub fn compile_dry_file<'db>(
152+
db: &'db dyn Db,
153+
parser_entry: FileCompileInput<'db>,
154+
) -> Option<ModWrapper<'db>> {
152155
if parser_entry.file(db).ends_with(".toml") {
153156
log::error!("lsp error: toml file {}", parser_entry.file(db));
154157
// skip toml
@@ -197,7 +200,7 @@ pub fn process_llvm_ir<'a>(
197200
) -> (Module<'a>, Vec<PathBuf>) {
198201
use inkwell::memory_buffer::MemoryBuffer;
199202

200-
let mods = compile_dry::accumulated::<ModBuffer>(db, docs);
203+
let mods: Vec<ModBuffer> = compile_dry::accumulated::<ModBuffer>(db, docs);
201204

202205
let total_steps = 3;
203206
let pb = ProgressBar::hidden();
@@ -211,6 +214,7 @@ pub fn process_llvm_ir<'a>(
211214
let llvmmod = ctx.create_module("main");
212215

213216
for m in mods {
217+
let m = m.0;
214218
pb.inc(1);
215219
let mem = &m.buf;
216220
let m = m.path;
@@ -370,7 +374,7 @@ pub fn pl_link(llvmmod: Module, oxbjs: Vec<PathBuf>, out: String, op: Options) {
370374

371375
#[cfg(not(feature = "llvm"))]
372376
#[salsa::tracked]
373-
pub fn compile(db: &dyn Db, docs: MemDocsInput, out: String, op: Options) {
377+
pub fn compile(db: &'db dyn Db, docs: MemDocsInput, out: String, op: Options) {
374378
unimplemented!()
375379
}
376380

src/ast/compiler/options.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ impl HashOptimizationLevel {
5959
/// lsp action type
6060
#[derive(Debug, Clone, PartialEq, Eq, Copy, Hash)]
6161
pub enum ActionType {
62-
Completion,
6362
GotoDef,
6463
FindReferences,
65-
SemanticTokensFull,
6664
Diagnostic,
6765
Hover,
6866
Compile,
@@ -73,5 +71,6 @@ pub enum ActionType {
7371
Hint,
7472
DocSymbol,
7573
SignatureHelp,
76-
CodeLens,
74+
#[cfg(test)]
75+
Completion,
7776
}

src/ast/diag.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,16 @@ impl<'a> Cache<&str> for PLFileCache<'a> {
507507
pub(crate) fn ensure_no_error(db: &dyn Db, docs: MemDocsInput) {
508508
let mut errs_num = 0;
509509
let mut warn_num = 0;
510-
let errs = compile_dry::accumulated::<Diagnostics>(db, docs);
510+
let mut errs = compile_dry::accumulated::<Diagnostics>(db, docs);
511511
if !errs.is_empty() {
512-
print_diags(errs, docs, db, &mut errs_num, &mut warn_num, false);
512+
print_diags(
513+
errs.drain(..).map(|e| e.0).collect(),
514+
docs,
515+
db,
516+
&mut errs_num,
517+
&mut warn_num,
518+
false,
519+
);
513520
if errs_num > 0 {
514521
eprintln!(
515522
"check failed: {} error(s), {} warning(s)",

0 commit comments

Comments
 (0)