Skip to content

Commit 63484d5

Browse files
committed
Emit EqGoals for projections / simplify
1 parent a1e2c36 commit 63484d5

File tree

2 files changed

+16
-37
lines changed

2 files changed

+16
-37
lines changed

chalk-solve/src/clauses/env_elaborator.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
use super::program_clauses::ToProgramClauses;
22
use crate::clauses::builder::ClauseBuilder;
33
use crate::clauses::{match_alias_ty, match_ty};
4-
use crate::AliasEq;
54
use crate::DomainGoal;
65
use crate::FromEnv;
76
use crate::ProgramClause;
87
use crate::RustIrDatabase;
98
use crate::Ty;
10-
use crate::WhereClause;
119
use crate::{debug_span, TyData};
1210
use chalk_ir::interner::Interner;
1311
use chalk_ir::visit::{Visit, Visitor};
@@ -89,32 +87,25 @@ impl<'me, I: Interner> Visitor<'me, I> for EnvElaborator<'me, I> {
8987
}
9088

9189
fn visit_domain_goal(&mut self, domain_goal: &DomainGoal<I>, outer_binder: DebruijnIndex) {
92-
match domain_goal {
93-
DomainGoal::FromEnv(from_env) => {
94-
debug_span!("visit_domain_goal", ?from_env);
95-
match from_env {
96-
FromEnv::Trait(trait_ref) => {
97-
let trait_datum = self.db.trait_datum(trait_ref.trait_id);
90+
if let DomainGoal::FromEnv(from_env) = domain_goal {
91+
debug_span!("visit_domain_goal", ?from_env);
92+
match from_env {
93+
FromEnv::Trait(trait_ref) => {
94+
let trait_datum = self.db.trait_datum(trait_ref.trait_id);
9895

99-
trait_datum.to_program_clauses(&mut self.builder, self.environment);
96+
trait_datum.to_program_clauses(&mut self.builder, self.environment);
10097

101-
// If we know that `T: Iterator`, then we also know
102-
// things about `<T as Iterator>::Item`, so push those
103-
// implied bounds too:
104-
for &associated_ty_id in &trait_datum.associated_ty_ids {
105-
self.db
106-
.associated_ty_data(associated_ty_id)
107-
.to_program_clauses(&mut self.builder, self.environment);
108-
}
98+
// If we know that `T: Iterator`, then we also know
99+
// things about `<T as Iterator>::Item`, so push those
100+
// implied bounds too:
101+
for &associated_ty_id in &trait_datum.associated_ty_ids {
102+
self.db
103+
.associated_ty_data(associated_ty_id)
104+
.to_program_clauses(&mut self.builder, self.environment);
109105
}
110-
FromEnv::Ty(ty) => ty.visit_with(self, outer_binder),
111106
}
107+
FromEnv::Ty(ty) => ty.visit_with(self, outer_binder),
112108
}
113-
DomainGoal::Holds(WhereClause::AliasEq(AliasEq { alias, ty })) => {
114-
match_alias_ty(&mut self.builder, self.environment, alias);
115-
ty.visit_with(self, outer_binder);
116-
}
117-
_ => {}
118109
}
119110
}
120111
}

chalk-solve/src/clauses/syntactic_eq.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use chalk_ir::{
44
cast::Cast,
55
fold::{shift::Shift, Fold, Folder, SuperFold},
66
interner::Interner,
7-
AliasEq, AliasTy, Binders, BoundVar, DebruijnIndex, EqGoal, Fallible, Goal, GoalData, Goals,
7+
AliasTy, Binders, BoundVar, DebruijnIndex, EqGoal, Fallible, Goal, GoalData, Goals,
88
ProgramClause, ProgramClauseData, ProgramClauseImplication, QuantifierKind, Ty, TyData, TyKind,
99
VariableKind, VariableKinds,
1010
};
@@ -50,19 +50,7 @@ impl<'i, I: Interner> Folder<'i, I> for SynEqFolder<'i, I> {
5050

5151
let new_ty = TyData::BoundVar(bound_var).intern(interner);
5252
match ty.data(interner) {
53-
TyData::Alias(alias @ AliasTy::Projection(_)) => {
54-
self.new_params.push(VariableKind::Ty(TyKind::General));
55-
self.new_goals.push(
56-
AliasEq {
57-
alias: alias.clone(),
58-
ty: new_ty.clone(),
59-
}
60-
.cast(interner),
61-
);
62-
self.binders_len += 1;
63-
Ok(new_ty)
64-
}
65-
TyData::Function(_) => {
53+
TyData::Alias(AliasTy::Projection(_)) | TyData::Function(_) => {
6654
self.new_params.push(VariableKind::Ty(TyKind::General));
6755
self.new_goals.push(
6856
EqGoal {

0 commit comments

Comments
 (0)