Skip to content

Commit 6c15a42

Browse files
committed
Move ObjectSafe fact generation closer to where it is needed
1 parent d7935b5 commit 6c15a42

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

chalk-solve/src/clauses.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ fn program_clauses_that_could_match<I: Interner>(
249249
db.trait_datum(trait_ref.trait_id)
250250
.to_program_clauses(builder);
251251
}
252-
DomainGoal::ObjectSafe(trait_id) => db.trait_datum(*trait_id).to_program_clauses(builder),
252+
DomainGoal::ObjectSafe(trait_id) => {
253+
if builder.db.is_object_safe(*trait_id) {
254+
builder.push_fact(DomainGoal::ObjectSafe(*trait_id));
255+
}
256+
}
253257
DomainGoal::WellFormed(WellFormed::Ty(ty))
254258
| DomainGoal::IsUpstream(ty)
255259
| DomainGoal::DownstreamType(ty)

chalk-solve/src/clauses/program_clauses.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,6 @@ impl<I: Interner> ToProgramClauses<I> for TraitDatum<I> {
540540
);
541541
}
542542

543-
// Object safety check
544-
if builder.db.is_object_safe(trait_ref.trait_id) {
545-
builder.push_fact(DomainGoal::ObjectSafe(trait_ref.trait_id));
546-
}
547-
548543
// Reverse implied bound rules: given (e.g.) `trait Foo: Bar + Baz`,
549544
// we create rules like:
550545
//

0 commit comments

Comments
 (0)