Skip to content

Commit 9ac4195

Browse files
committed
Elaborate AliasEq goals
1 parent 656146d commit 9ac4195

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

chalk-solve/src/clauses/env_elaborator.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
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;
45
use crate::DomainGoal;
56
use crate::FromEnv;
67
use crate::ProgramClause;
78
use crate::RustIrDatabase;
89
use crate::Ty;
9-
use crate::{debug_span, TyKind};
10+
use crate::WhereClause;
11+
use crate::{debug_span, TyData};
1012
use chalk_ir::interner::Interner;
1113
use chalk_ir::visit::{Visit, Visitor};
1214
use chalk_ir::{DebruijnIndex, Environment};
@@ -87,25 +89,32 @@ impl<'me, I: Interner> Visitor<'me, I> for EnvElaborator<'me, I> {
8789
}
8890

8991
fn visit_domain_goal(&mut self, domain_goal: &DomainGoal<I>, outer_binder: DebruijnIndex) {
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);
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);
9598

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

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);
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+
}
105109
}
110+
FromEnv::Ty(ty) => ty.visit_with(self, outer_binder),
106111
}
107-
FromEnv::Ty(ty) => ty.visit_with(self, outer_binder),
108112
}
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+
_ => {}
109118
}
110119
}
111120
}

0 commit comments

Comments
 (0)