Review changes
This commit is contained in:
parent
66c179946b
commit
3dea68de1d
67 changed files with 581 additions and 590 deletions
|
@ -82,35 +82,35 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
|||
) -> chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'tcx>>> {
|
||||
let clauses = self.environment.into_iter().map(|predicate| {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, predicate.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, predicate.kind());
|
||||
let consequence = match predicate {
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
|
||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateAtom::Trait(predicate, _) => chalk_ir::DomainGoal::FromEnv(
|
||||
ty::PredicateKind::Trait(predicate, _) => chalk_ir::DomainGoal::FromEnv(
|
||||
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
|
||||
),
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
ty::PredicateKind::RegionOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
}),
|
||||
),
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
ty::PredicateKind::TypeOutlives(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
}),
|
||||
),
|
||||
ty::PredicateAtom::Projection(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
ty::PredicateKind::Projection(predicate) => chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||
),
|
||||
ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..) => bug!("unexpected predicate {}", predicate),
|
||||
ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..) => bug!("unexpected predicate {}", predicate),
|
||||
};
|
||||
let value = chalk_ir::ProgramClauseImplication {
|
||||
consequence,
|
||||
|
@ -134,15 +134,15 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
|||
impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predicate<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
|
||||
let value = match predicate {
|
||||
ty::PredicateAtom::Trait(predicate, _) => {
|
||||
ty::PredicateKind::Trait(predicate, _) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
|
@ -150,7 +150,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
}),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => {
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
|
@ -158,12 +158,12 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
}),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::Projection(predicate) => {
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::Holds(
|
||||
chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)),
|
||||
))
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(arg) => match arg.unpack() {
|
||||
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => match ty.kind() {
|
||||
// FIXME(chalk): In Chalk, a placeholder is WellFormed if it
|
||||
// `FromEnv`. However, when we "lower" Params, we don't update
|
||||
|
@ -183,7 +183,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
GenericArgKind::Lifetime(lt) => bug!("unexpect well formed predicate: {:?}", lt),
|
||||
},
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(t) => chalk_ir::GoalData::DomainGoal(
|
||||
ty::PredicateKind::ObjectSafe(t) => chalk_ir::GoalData::DomainGoal(
|
||||
chalk_ir::DomainGoal::ObjectSafe(chalk_ir::TraitId(t)),
|
||||
),
|
||||
|
||||
|
@ -191,13 +191,13 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
//
|
||||
// We can defer this, but ultimately we'll want to express
|
||||
// some of these in terms of chalk operations.
|
||||
ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..) => {
|
||||
ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..) => {
|
||||
chalk_ir::GoalData::All(chalk_ir::Goals::empty(interner))
|
||||
}
|
||||
ty::PredicateAtom::TypeWellFormedFromEnv(ty) => chalk_ir::GoalData::DomainGoal(
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(ty) => chalk_ir::GoalData::DomainGoal(
|
||||
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner))),
|
||||
),
|
||||
};
|
||||
|
@ -568,34 +568,34 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
|||
interner: &RustInterner<'tcx>,
|
||||
) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
let value = match predicate {
|
||||
ty::PredicateAtom::Trait(predicate, _) => {
|
||||
ty::PredicateKind::Trait(predicate, _) => {
|
||||
Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => {
|
||||
ty::PredicateKind::RegionOutlives(predicate) => {
|
||||
Some(chalk_ir::WhereClause::LifetimeOutlives(chalk_ir::LifetimeOutlives {
|
||||
a: predicate.0.lower_into(interner),
|
||||
b: predicate.1.lower_into(interner),
|
||||
}))
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(predicate) => {
|
||||
ty::PredicateKind::TypeOutlives(predicate) => {
|
||||
Some(chalk_ir::WhereClause::TypeOutlives(chalk_ir::TypeOutlives {
|
||||
ty: predicate.0.lower_into(interner),
|
||||
lifetime: predicate.1.lower_into(interner),
|
||||
}))
|
||||
}
|
||||
ty::PredicateAtom::Projection(predicate) => {
|
||||
ty::PredicateKind::Projection(predicate) => {
|
||||
Some(chalk_ir::WhereClause::AliasEq(predicate.lower_into(interner)))
|
||||
}
|
||||
ty::PredicateAtom::WellFormed(_ty) => None,
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
||||
ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("unexpected predicate {}", &self)
|
||||
}
|
||||
};
|
||||
|
@ -699,28 +699,28 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
|
|||
interner: &RustInterner<'tcx>,
|
||||
) -> Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.bound_atom());
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
match predicate {
|
||||
ty::PredicateAtom::Trait(predicate, _) => Some(chalk_ir::Binders::new(
|
||||
ty::PredicateKind::Trait(predicate, _) => Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::TraitBound(
|
||||
predicate.trait_ref.lower_into(interner),
|
||||
),
|
||||
)),
|
||||
ty::PredicateAtom::Projection(predicate) => Some(chalk_ir::Binders::new(
|
||||
ty::PredicateKind::Projection(predicate) => Some(chalk_ir::Binders::new(
|
||||
binders,
|
||||
chalk_solve::rust_ir::InlineBound::AliasEqBound(predicate.lower_into(interner)),
|
||||
)),
|
||||
ty::PredicateAtom::TypeOutlives(_predicate) => None,
|
||||
ty::PredicateAtom::WellFormed(_ty) => None,
|
||||
ty::PredicateKind::TypeOutlives(_predicate) => None,
|
||||
ty::PredicateKind::WellFormed(_ty) => None,
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
|
||||
ty::PredicateKind::RegionOutlives(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
bug!("unexpected predicate {}", &self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,27 +94,27 @@ fn compute_implied_outlives_bounds<'tcx>(
|
|||
// region relationships.
|
||||
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
|
||||
assert!(!obligation.has_escaping_bound_vars());
|
||||
match obligation.predicate.bound_atom().no_bound_vars() {
|
||||
match obligation.predicate.kind().no_bound_vars() {
|
||||
None => vec![],
|
||||
Some(pred) => match pred {
|
||||
ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => vec![],
|
||||
ty::PredicateAtom::WellFormed(arg) => {
|
||||
ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => vec![],
|
||||
ty::PredicateKind::WellFormed(arg) => {
|
||||
wf_args.push(arg);
|
||||
vec![]
|
||||
}
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r_a, r_b)) => {
|
||||
vec![OutlivesBound::RegionSubRegion(r_b, r_a)]
|
||||
}
|
||||
|
||||
ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
|
||||
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, r_b)) => {
|
||||
let ty_a = infcx.resolve_vars_if_possible(ty_a);
|
||||
let mut components = smallvec![];
|
||||
tcx.push_outlives_components(ty_a, &mut components);
|
||||
|
|
|
@ -46,16 +46,16 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>(
|
|||
}
|
||||
|
||||
fn not_outlives_predicate(p: &ty::Predicate<'tcx>) -> bool {
|
||||
match p.skip_binders() {
|
||||
ty::PredicateAtom::RegionOutlives(..) | ty::PredicateAtom::TypeOutlives(..) => false,
|
||||
ty::PredicateAtom::Trait(..)
|
||||
| ty::PredicateAtom::Projection(..)
|
||||
| ty::PredicateAtom::WellFormed(..)
|
||||
| ty::PredicateAtom::ObjectSafe(..)
|
||||
| ty::PredicateAtom::ClosureKind(..)
|
||||
| ty::PredicateAtom::Subtype(..)
|
||||
| ty::PredicateAtom::ConstEvaluatable(..)
|
||||
| ty::PredicateAtom::ConstEquate(..)
|
||||
| ty::PredicateAtom::TypeWellFormedFromEnv(..) => true,
|
||||
match p.kind().skip_binder() {
|
||||
ty::PredicateKind::RegionOutlives(..) | ty::PredicateKind::TypeOutlives(..) => false,
|
||||
ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::Projection(..)
|
||||
| ty::PredicateKind::WellFormed(..)
|
||||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::Subtype(..)
|
||||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => true,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
|||
self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
|
||||
|
||||
self.prove_predicate(
|
||||
ty::PredicateAtom::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
|
||||
ty::PredicateKind::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
|
|||
// them? This would only be relevant if some input
|
||||
// type were ill-formed but did not appear in `ty`,
|
||||
// which...could happen with normalization...
|
||||
self.prove_predicate(ty::PredicateAtom::WellFormed(ty.into()).to_predicate(self.tcx()));
|
||||
self.prove_predicate(ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue