Skip to content

Commit

Permalink
refactor(sol-thir): fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aripiprazole committed May 29, 2024
1 parent b8cad73 commit 16cfdda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sol-thir/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum Term {

impl Default for Term {
fn default() -> Self {
Term::U
Term::InsertedMeta(shared::MetaVar::new(None))
}
}

Expand Down
4 changes: 2 additions & 2 deletions sol-thir/src/unification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ impl Value {
}
(Lam(_, _, clos_a) , rhs) => {
clos_a.apply(db, Value::new_var(ctx.lvl(db), None))?
.unify(db, ctx.increase_level(db), rhs.apply(db, Value::new_var(ctx.lvl(db), None))?)
.unify(db, ctx.increase_level(db), rhs.apply_to_spine(db, Value::new_var(ctx.lvl(db), None))?)
}
(lhs , Lam(_, _, clos_b)) => {
lhs.apply(db, Value::new_var(ctx.lvl(db), None))?
lhs.apply_to_spine(db, Value::new_var(ctx.lvl(db), None))?
.unify(db, ctx.increase_level(db), clos_b.apply(db, Value::new_var(ctx.lvl(db), None))?)
}

Expand Down
17 changes: 3 additions & 14 deletions sol-thir/src/value.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use sol_diagnostic::fail;
use unification::UnifyError;
use shared::MetaVar;

use super::*;

Expand All @@ -19,7 +18,7 @@ pub enum Value {

impl Default for Value {
fn default() -> Self {
Value::U
Value::Flexible(MetaVar::new(None), vec![])
}
}

Expand All @@ -42,16 +41,6 @@ impl Value {
}
}

pub fn apply(self, db: &dyn ThirDb, argument: Value) -> sol_diagnostic::Result<Value> {
match self {
_ => {
let this = db.thir_quote(debruijin::Level::new(db, 0), self.clone())?;
let argument = db.thir_quote(debruijin::Level::new(db, 0), argument.clone())?;
fail(UnifyError::CouldNotApply(this, argument))
}
}
}

pub fn apply_with_spine(
self,
db: &dyn ThirDb,
Expand All @@ -60,7 +49,7 @@ impl Value {
spine
.into_iter()
.rev()
.fold(Ok(self), |acc, next| Ok(acc?.apply_to_spine(db, next)?))
.try_fold(self, |acc, next| acc.apply_to_spine(db, next))
}

pub fn apply_to_spine(self, db: &dyn ThirDb, argument: Value) -> sol_diagnostic::Result<Value> {
Expand Down

0 comments on commit 16cfdda

Please sign in to comment.