Skip to content

Commit a60a444

Browse files
committed
feat: Update salsa
Now based on trait objects, we end up with a lot less duplicated code. Smaller binaries and faster compiles!
1 parent 7eae498 commit a60a444

File tree

9 files changed

+258
-266
lines changed

9 files changed

+258
-266
lines changed

Cargo.lock

Lines changed: 28 additions & 56 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
@@ -43,7 +43,7 @@ futures = { version = "0.3.1", default-features = false }
4343
codespan = "0.9"
4444
codespan-reporting = "0.9"
4545
pin-project-lite = { version = "0.1", optional = true }
46-
salsa = { version = "0.14.2", package = "gluon-salsa" }
46+
salsa = { path = "../salsa" }
4747

4848
serde = { version = "1.0.0", optional = true }
4949
serde_state = { version = "0.4", optional = true }

base/src/resolve.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ where
6767
{
6868
pub fn canonical_alias<'t, F>(
6969
&mut self,
70-
env: &dyn TypeEnv<Type = T>,
70+
env: &(dyn TypeEnv<Type = T> + '_),
7171
interner: &mut impl TypeContext<Symbol, T>,
7272
typ: &'t T,
7373
mut canonical: F,
@@ -105,7 +105,7 @@ where
105105

106106
pub fn remove_aliases_to_concrete<'a>(
107107
&mut self,
108-
env: &dyn TypeEnv<Type = T>,
108+
env: &(dyn TypeEnv<Type = T> + '_),
109109
interner: &mut impl TypeContext<Symbol, T>,
110110
mut typ: T,
111111
) -> Result<T, Error> {
@@ -139,7 +139,7 @@ where
139139

140140
pub fn remove_aliases(
141141
&mut self,
142-
env: &dyn TypeEnv<Type = T>,
142+
env: &(dyn TypeEnv<Type = T> + '_),
143143
interner: &mut impl TypeContext<Symbol, T>,
144144
typ: T,
145145
) -> Result<T, Error> {
@@ -148,7 +148,7 @@ where
148148

149149
pub fn remove_aliases_predicate(
150150
&mut self,
151-
env: &dyn TypeEnv<Type = T>,
151+
env: &(dyn TypeEnv<Type = T> + '_),
152152
interner: &mut impl TypeContext<Symbol, T>,
153153
mut typ: T,
154154
mut predicate: impl FnMut(&AliasData<Symbol, T>) -> bool,
@@ -163,7 +163,7 @@ where
163163

164164
pub fn remove_alias(
165165
&mut self,
166-
env: &dyn TypeEnv<Type = T>,
166+
env: &(dyn TypeEnv<Type = T> + '_),
167167
interner: &mut impl TypeContext<Symbol, T>,
168168
typ: &T,
169169
predicate: impl FnOnce(&AliasData<Symbol, T>) -> bool,
@@ -181,7 +181,7 @@ where
181181

182182
pub fn remove_alias_to_concrete<'a>(
183183
&mut self,
184-
env: &'a dyn TypeEnv<Type = T>,
184+
env: &'a (dyn TypeEnv<Type = T> + '_),
185185
interner: &mut impl TypeContext<Symbol, T>,
186186
typ: &'a T,
187187
predicate: impl FnOnce(&AliasData<Symbol, T>) -> bool,
@@ -238,7 +238,7 @@ where
238238

239239
/// Removes type aliases from `typ` until it is an actual type
240240
pub fn remove_aliases<T>(
241-
env: &dyn TypeEnv<Type = T>,
241+
env: &(dyn TypeEnv<Type = T> + '_),
242242
interner: &mut impl TypeContext<Symbol, T>,
243243
mut typ: T,
244244
) -> T
@@ -255,8 +255,7 @@ where
255255
}
256256

257257
pub fn remove_aliases_cow<'t, T>(
258-
env: &dyn TypeEnv<Type = T>,
259-
258+
env: &(dyn TypeEnv<Type = T> + '_),
260259
interner: &mut impl TypeContext<Symbol, T>,
261260
typ: &'t T,
262261
) -> Cow<'t, T>
@@ -275,7 +274,7 @@ where
275274
/// Resolves aliases until `canonical` returns `true` for an alias in which case it returns the
276275
/// type that directly contains that alias
277276
pub fn canonical_alias<'t, F, T>(
278-
env: &dyn TypeEnv<Type = T>,
277+
env: &(dyn TypeEnv<Type = T> + '_),
279278
interner: &mut impl TypeContext<Symbol, T>,
280279
typ: &'t T,
281280
mut canonical: F,
@@ -313,7 +312,7 @@ where
313312
/// Expand `typ` if it is an alias that can be expanded and return the expanded type.
314313
/// Returns `None` if the type is not an alias or the alias could not be expanded.
315314
pub fn remove_alias<T>(
316-
env: &dyn TypeEnv<Type = T>,
315+
env: &(dyn TypeEnv<Type = T> + '_),
317316
interner: &mut impl TypeContext<Symbol, T>,
318317
typ: &T,
319318
) -> Result<Option<T>, Error>
@@ -338,7 +337,7 @@ where
338337
}
339338

340339
pub fn peek_alias<'t, T>(
341-
env: &'t dyn TypeEnv<Type = T>,
340+
env: &(dyn TypeEnv<Type = T> + '_),
342341
typ: &'t T,
343342
) -> Result<Option<AliasRef<Symbol, T>>, Error>
344343
where

repl/src/repl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ fn eval_line(
374374

375375
async fn eval_line_(vm: RootedThread, line: &str) -> gluon::Result<()> {
376376
let mut db = vm.get_database();
377+
let mut db = gluon::salsa::OwnedDb::<dyn gluon::query::Compilation>::from(&mut db);
377378
let mut module_compiler = vm.module_compiler(&mut db);
378379
let mut is_let_binding = false;
379380
let mut eval_expr = {

0 commit comments

Comments
 (0)