Skip to content

Commit cd6589c

Browse files
committed
move to the salsa 0.10.x
We also need syn 0.15.29 or so to get `syn::Result`
1 parent 17836c4 commit cd6589c

File tree

4 files changed

+64
-63
lines changed

4 files changed

+64
-63
lines changed

Cargo.lock

Lines changed: 37 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ itertools = "0.7.8"
2020
lalrpop-intern = "0.15.1"
2121
petgraph = "0.4.13"
2222
rustyline = "1.0"
23-
salsa = "0.9.1"
23+
salsa = "0.10.0"
2424
serde = "1.0"
2525
serde_derive = "1.0"
2626
stacker = "0.1.5"

src/db.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#![allow(non_camel_case_types)]
22

3-
use crate::query::{self, ProgramSolverChoice, ProgramText};
3+
use crate::query::{Lowering, LoweringDatabase};
44
use chalk_solve::solve::SolverChoice;
55
use salsa::Database;
66
use std::sync::Arc;
77

8+
#[salsa::database(Lowering)]
89
#[derive(Default)]
910
pub struct ChalkDatabase {
1011
runtime: salsa::Runtime<ChalkDatabase>,
@@ -24,22 +25,9 @@ impl ChalkDatabase {
2425
) -> R {
2526
let mut db = ChalkDatabase::default();
2627

27-
db.query_mut(ProgramText).set((), program_text);
28-
db.query_mut(ProgramSolverChoice).set((), solver_choice);
28+
db.set_program_text(program_text);
29+
db.set_solver_choice(solver_choice);
2930

3031
f(&mut db)
3132
}
3233
}
33-
34-
salsa::database_storage! {
35-
pub struct DatabaseStorage for ChalkDatabase {
36-
impl query::LoweringDatabase {
37-
fn program_text() for query::ProgramText;
38-
fn solver_choice() for query::ProgramSolverChoice;
39-
fn program_ir() for query::ProgramIr;
40-
fn lowered_program() for query::LoweredProgram;
41-
fn checked_program() for query::CheckedProgram;
42-
fn environment() for query::Environment;
43-
}
44-
}
45-
}

src/query.rs

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,28 @@ use chalk_ir::ProgramEnvironment;
99
use chalk_solve::solve::SolverChoice;
1010
use std::sync::Arc;
1111

12-
salsa::query_group! {
13-
pub trait LoweringDatabase: salsa::Database {
14-
fn program_text() -> Arc<String> {
15-
type ProgramText;
16-
17-
storage input;
18-
}
19-
20-
fn solver_choice() -> SolverChoice {
21-
type ProgramSolverChoice;
22-
23-
storage input;
24-
}
25-
26-
// FIXME: Result<..., String> is only needed because the error type is not clone
27-
28-
/// The program IR before recording specialization priorities.
29-
/// Do not use this query directly.
30-
fn program_ir() -> Result<Arc<rust_ir::Program>, String> {
31-
type ProgramIr;
32-
}
33-
34-
/// The lowered IR.
35-
fn lowered_program() -> Result<Arc<rust_ir::Program>, String> {
36-
type LoweredProgram;
37-
}
38-
39-
/// The lowered IR, with checks performed.
40-
fn checked_program() -> Result<Arc<rust_ir::Program>, String> {
41-
type CheckedProgram;
42-
}
43-
44-
/// The program as logic.
45-
fn environment() -> Result<Arc<ProgramEnvironment>, String> {
46-
type Environment;
47-
}
48-
}
12+
#[salsa::query_group(Lowering)]
13+
pub trait LoweringDatabase {
14+
#[salsa::input]
15+
fn program_text(&self) -> Arc<String>;
16+
17+
#[salsa::input]
18+
fn solver_choice(&self) -> SolverChoice;
19+
20+
// FIXME: Result<..., String> is only needed because the error type is not clone
21+
22+
/// The program IR before recording specialization priorities.
23+
/// Do not use this query directly.
24+
fn program_ir(&self) -> Result<Arc<rust_ir::Program>, String>;
25+
26+
/// The lowered IR.
27+
fn lowered_program(&self) -> Result<Arc<rust_ir::Program>, String>;
28+
29+
/// The lowered IR, with checks performed.
30+
fn checked_program(&self) -> Result<Arc<rust_ir::Program>, String>;
31+
32+
/// The program as logic.
33+
fn environment(&self) -> Result<Arc<ProgramEnvironment>, String>;
4934
}
5035

5136
fn program_ir(db: &impl LoweringDatabase) -> Result<Arc<rust_ir::Program>, String> {

0 commit comments

Comments
 (0)