Skip to content

Commit 26cf45e

Browse files
committed
Use derives
1 parent e99d08f commit 26cf45e

File tree

6 files changed

+20
-170
lines changed

6 files changed

+20
-170
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chalk-engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ default = []
1616
rustc-hash = { version = "1.1.0" }
1717

1818
chalk-base = { version = "0.10.1-dev", path = "../chalk-base" }
19+
chalk-derive = { version = "0.10.1-dev", path = "../chalk-derive" }
1920
chalk-ir = { version = "0.10.1-dev", path = "../chalk-ir" }

chalk-engine/src/boring_impls.rs

Lines changed: 0 additions & 162 deletions
This file was deleted.

chalk-engine/src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ extern crate chalk_base;
5959
use std::cmp::min;
6060
use std::usize;
6161

62-
use chalk_ir::interner::Interner;
62+
use chalk_derive::{Fold, HasInterner, Visit};
63+
use chalk_ir::interner::{Interner, TargetInterner};
64+
use chalk_ir::visit::VisitResult;
6365
use chalk_ir::{
64-
AnswerSubst, Canonical, ConstrainedSubst, Constraint, Goal, InEnvironment, Substitution,
66+
AnswerSubst, Canonical, ConstrainedSubst, Constraint, DebruijnIndex, Goal, InEnvironment,
67+
Substitution,
6568
};
6669

67-
mod boring_impls;
6870
pub mod context;
6971
mod derived;
7072
pub mod forest;
@@ -92,7 +94,7 @@ index_struct! {
9294
}
9395

9496
/// The paper describes these as `A :- D | G`.
95-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
97+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Fold, Visit, HasInterner)]
9698
pub struct ExClause<I: Interner> {
9799
/// The substitution which, applied to the goal of our table,
98100
/// would yield A.
@@ -176,7 +178,7 @@ impl TimeStamp {
176178
///
177179
/// trying to solve `?T: Foo` would immediately require solving `?T:
178180
/// Sized`, and hence would flounder.
179-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
181+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Fold, Visit)]
180182
pub struct FlounderedSubgoal<I: Interner> {
181183
/// Literal that floundered.
182184
pub floundered_literal: Literal<I>,
@@ -217,7 +219,7 @@ pub struct CompleteAnswer<I: Interner> {
217219
}
218220

219221
/// Either `A` or `~A`, where `A` is a `Env |- Goal`.
220-
#[derive(Clone, Debug)]
222+
#[derive(Clone, Debug, Fold, Visit)]
221223
pub enum Literal<I: Interner> {
222224
// FIXME: pub b/c fold
223225
Positive(InEnvironment<Goal<I>>),
@@ -281,3 +283,9 @@ impl Minimums {
281283
min(self.positive, self.negative)
282284
}
283285
}
286+
287+
chalk_ir::copy_fold!(TableIndex);
288+
chalk_ir::copy_fold!(TimeStamp);
289+
290+
chalk_ir::const_visit!(TableIndex);
291+
chalk_ir::const_visit!(TimeStamp);

chalk-ir/src/fold/boring_impls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ macro_rules! copy_fold {
233233
};
234234
}
235235

236-
copy_fold!(UniverseIndex);
236+
copy_fold!(bool);
237237
copy_fold!(usize);
238+
copy_fold!(UniverseIndex);
238239
copy_fold!(PlaceholderIndex);
239240
copy_fold!(QuantifierKind);
240241
copy_fold!(DebruijnIndex);

chalk-ir/src/visit/boring_impls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ macro_rules! const_visit {
197197
};
198198
}
199199

200-
const_visit!(UniverseIndex);
200+
const_visit!(bool);
201201
const_visit!(usize);
202+
const_visit!(UniverseIndex);
202203
const_visit!(PlaceholderIndex);
203204
const_visit!(QuantifierKind);
204205
const_visit!(DebruijnIndex);

0 commit comments

Comments
 (0)