Skip to content

Commit

Permalink
Change WellFormed/FromEnv::Normalize to `WellFormed/FromEnv::Projec…
Browse files Browse the repository at this point in the history
…tionEq`
  • Loading branch information
scalexm committed Feb 8, 2018
1 parent 91eda35 commit 249bd61
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/fold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ macro_rules! enum_fold {
enum_fold!(PolarizedTraitRef[] { Positive(a), Negative(a) });
enum_fold!(ParameterKind[T,L] { Ty(a), Lifetime(a) } where T: Fold, L: Fold);
enum_fold!(DomainGoal[] { Implemented(a), ProjectionEq(a), Normalize(a), UnselectedNormalize(a), WellFormed(a), FromEnv(a), InScope(a) });
enum_fold!(WellFormed[] { Ty(a), TraitRef(a), Normalize(a) });
enum_fold!(FromEnv[] { Ty(a), TraitRef(a), Normalize(a) });
enum_fold!(WellFormed[] { Ty(a), TraitRef(a), ProjectionEq(a) });
enum_fold!(FromEnv[] { Ty(a), TraitRef(a), ProjectionEq(a) });
enum_fold!(LeafGoal[] { EqGoal(a), DomainGoal(a) });
enum_fold!(Constraint[] { LifetimeEq(a, b) });
enum_fold!(Goal[] { Quantified(qkind, subgoal), Implies(wc, subgoal), And(g1, g2), Not(g), Leaf(wc),
Expand Down
4 changes: 2 additions & 2 deletions src/ir/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Debug for WellFormed {
let value: &Debug = match *self {
WellFormed::Ty(ref t) => t,
WellFormed::TraitRef(ref t) => t,
WellFormed::Normalize(ref t) => t,
WellFormed::ProjectionEq(ref t) => t,
};
write!(fmt, "WellFormed({:?})", value)
}
Expand All @@ -213,7 +213,7 @@ impl Debug for FromEnv {
let value: &Debug = match *self {
FromEnv::Ty(ref t) => t,
FromEnv::TraitRef(ref t) => t,
FromEnv::Normalize(ref t) => t,
FromEnv::ProjectionEq(ref t) => t,
};
write!(fmt, "FromEnv({:?})", value)
}
Expand Down
8 changes: 4 additions & 4 deletions src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl DomainGoal {
crate fn into_well_formed_clause(self) -> DomainGoal {
match self {
DomainGoal::Implemented(tr) => DomainGoal::WellFormed(WellFormed::TraitRef(tr)),
DomainGoal::Normalize(n) => DomainGoal::WellFormed(WellFormed::Normalize(n)),
DomainGoal::ProjectionEq(n) => DomainGoal::WellFormed(WellFormed::ProjectionEq(n)),
goal => goal,
}
}
Expand All @@ -485,7 +485,7 @@ impl DomainGoal {
crate fn into_from_env_clause(self) -> DomainGoal {
match self {
DomainGoal::Implemented(tr) => DomainGoal::FromEnv(FromEnv::TraitRef(tr)),
DomainGoal::Normalize(n) => DomainGoal::FromEnv(FromEnv::Normalize(n)),
DomainGoal::ProjectionEq(n) => DomainGoal::FromEnv(FromEnv::ProjectionEq(n)),
goal => goal,
}
}
Expand Down Expand Up @@ -521,7 +521,7 @@ pub struct EqGoal {
pub enum WellFormed {
Ty(Ty),
TraitRef(TraitRef),
Normalize(Normalize),
ProjectionEq(ProjectionEq),
}

#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand All @@ -547,7 +547,7 @@ pub enum WellFormed {
pub enum FromEnv {
Ty(Ty),
TraitRef(TraitRef),
Normalize(Normalize),
ProjectionEq(ProjectionEq),
}

/// Proves that the given projection **normalizes** to the given
Expand Down
24 changes: 12 additions & 12 deletions src/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,9 @@ impl ir::AssociatedTyDatum {
// `Normalize(<T as Foo>::Assoc -> U)`
let normalize = ir::Normalize { projection: projection.clone(), ty: ty.clone() };

// `ProjectionEq(<T as Foo>::Assoc = U)`
let projection_eq = ir::ProjectionEq { projection: projection.clone(), ty };

// forall<T> {
// ProjectionEq(<T as Foo>::Assoc = U) :-
// Normalize(<T as Foo>::Assoc -> U)
Expand All @@ -1476,10 +1479,7 @@ impl ir::AssociatedTyDatum {
implication: ir::Binders {
binders: binders.clone(),
value: ir::ProgramClauseImplication {
consequence: ir::ProjectionEq {
projection: projection.clone(),
ty,
}.cast(),
consequence: projection_eq.clone().cast(),
conditions: vec![normalize.clone().cast()],
},
},
Expand All @@ -1492,16 +1492,16 @@ impl ir::AssociatedTyDatum {
//
// forall<T> {
// WellFormed(T: Foo<Assoc = U>) :-
// WellFormed(T: Foo), Normalize(<T as Foo>::Assoc -> U)
// WellFormed(T: Foo), ProjectionEq(<T as Foo>::Assoc = U)
// }
clauses.push(ir::ProgramClause {
implication: ir::Binders {
binders: binders.clone(),
value: ir::ProgramClauseImplication {
consequence: ir::WellFormed::Normalize(normalize.clone()).cast(),
consequence: ir::WellFormed::ProjectionEq(projection_eq.clone()).cast(),
conditions: vec![
normalize.clone().cast(),
ir::WellFormed::TraitRef(trait_ref.clone()).cast()
ir::WellFormed::TraitRef(trait_ref.clone()).cast(),
projection_eq.clone().cast()
],
}
}
Expand All @@ -1517,22 +1517,22 @@ impl ir::AssociatedTyDatum {
binders: binders.clone(),
value: ir::ProgramClauseImplication {
consequence: ir::FromEnv::TraitRef(trait_ref).cast(),
conditions: vec![ir::FromEnv::Normalize(normalize.clone()).cast()],
conditions: vec![ir::FromEnv::ProjectionEq(projection_eq.clone()).cast()],
},
}
});

// And the other one being:
//
// forall<T> {
// Normalize(<T as Foo>::Assoc -> U) :- FromEnv(T: Foo<Assoc = U>)
// ProjectionEq(<T as Foo>::Assoc = U) :- FromEnv(T: Foo<Assoc = U>)
// }
clauses.push(ir::ProgramClause {
implication: ir::Binders {
binders: binders,
value: ir::ProgramClauseImplication {
consequence: normalize.clone().cast(),
conditions: vec![ir::FromEnv::Normalize(normalize).cast()],
consequence: projection_eq.clone().cast(),
conditions: vec![ir::FromEnv::ProjectionEq(projection_eq).cast()],
},
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ enum_zip!(DomainGoal {
InScope,
});
enum_zip!(LeafGoal { DomainGoal, EqGoal });
enum_zip!(WellFormed { Ty, TraitRef, Normalize });
enum_zip!(FromEnv { Ty, TraitRef, Normalize });
enum_zip!(WellFormed { Ty, TraitRef, ProjectionEq });
enum_zip!(FromEnv { Ty, TraitRef, ProjectionEq });

// Annoyingly, Goal cannot use `enum_zip` because some variants have
// two parameters, and I'm too lazy to make the macro account for the
Expand Down

0 comments on commit 249bd61

Please sign in to comment.