1
Fork 0

TypeWellFormedInEnv

This commit is contained in:
Michael Goulet 2023-06-22 17:43:19 +00:00
parent fbdef58414
commit 374173cd99
26 changed files with 75 additions and 74 deletions

View file

@ -965,7 +965,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty::ClauseKind::RegionOutlives(_) ty::ClauseKind::RegionOutlives(_)
| ty::ClauseKind::ConstArgHasType(..) | ty::ClauseKind::ConstArgHasType(..)
| ty::ClauseKind::WellFormed(_) | ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => { | ty::ClauseKind::ConstEvaluatable(_)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => {
bug!() bug!()
} }
} }

View file

@ -554,6 +554,6 @@ fn trait_predicate_kind<'tcx>(
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None, | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => None,
} }
} }

View file

@ -53,7 +53,8 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
| ty::ClauseKind::Projection(_) | ty::ClauseKind::Projection(_)
| ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::ConstArgHasType(_, _)
| ty::ClauseKind::WellFormed(_) | ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => {} | ty::ClauseKind::ConstEvaluatable(_)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => {}
} }
} }

View file

@ -683,7 +683,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// inference variable. // inference variable.
| ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None, | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => None,
}, },
) )
} }

View file

@ -847,7 +847,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
| ty::ClauseKind::Projection(_) | ty::ClauseKind::Projection(_)
| ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::ConstArgHasType(_, _)
| ty::ClauseKind::WellFormed(_) | ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => None, | ty::ClauseKind::ConstEvaluatable(_)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => None,
} }
}); });

View file

@ -31,7 +31,8 @@ pub fn explicit_outlives_bounds<'tcx>(
| ty::ClauseKind::Projection(_) | ty::ClauseKind::Projection(_)
| ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::ConstArgHasType(_, _)
| ty::ClauseKind::WellFormed(_) | ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => None, | ty::ClauseKind::ConstEvaluatable(_)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => None,
}) })
} }

View file

@ -368,7 +368,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
.map(|predicate| elaboratable.child(predicate)), .map(|predicate| elaboratable.child(predicate)),
); );
} }
ty::PredicateKind::TypeWellFormedFromEnv(..) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
// Nothing to elaborate // Nothing to elaborate
} }
ty::PredicateKind::Ambiguous => {} ty::PredicateKind::Ambiguous => {}

View file

@ -1610,7 +1610,8 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
// Ignore bounds that a user can't type // Ignore bounds that a user can't type
| ClauseKind::WellFormed(..) | ClauseKind::WellFormed(..)
// FIXME(generic_const_exprs): `ConstEvaluatable` can be written // FIXME(generic_const_exprs): `ConstEvaluatable` can be written
| ClauseKind::ConstEvaluatable(..) => continue, | ClauseKind::ConstEvaluatable(..)
| ClauseKind::TypeWellFormedFromEnv(_) => continue,
}; };
if predicate.is_global() { if predicate.is_global() {
cx.emit_spanned_lint( cx.emit_spanned_lint(

View file

@ -287,7 +287,7 @@ impl FlagComputation {
self.add_const(expected); self.add_const(expected);
self.add_const(found); self.add_const(found);
} }
ty::PredicateKind::TypeWellFormedFromEnv(ty) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(ty)) => {
self.add_ty(ty); self.add_ty(ty);
} }
ty::PredicateKind::Ambiguous => {} ty::PredicateKind::Ambiguous => {}

View file

@ -555,7 +555,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
| PredicateKind::ConstEquate(_, _) | PredicateKind::ConstEquate(_, _)
| PredicateKind::Ambiguous | PredicateKind::Ambiguous
| PredicateKind::TypeWellFormedFromEnv(_) => true, | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(_)) => true,
} }
} }
} }
@ -661,6 +661,11 @@ pub enum ClauseKind<'tcx> {
/// Constant initializer must evaluate successfully. /// Constant initializer must evaluate successfully.
ConstEvaluatable(ty::Const<'tcx>), ConstEvaluatable(ty::Const<'tcx>),
/// Represents a type found in the environment that we can use for implied bounds.
///
/// Only used for Chalk.
TypeWellFormedFromEnv(Ty<'tcx>),
} }
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
@ -697,11 +702,6 @@ pub enum PredicateKind<'tcx> {
/// Constants must be equal. The first component is the const that is expected. /// Constants must be equal. The first component is the const that is expected.
ConstEquate(Const<'tcx>, Const<'tcx>), ConstEquate(Const<'tcx>, Const<'tcx>),
/// Represents a type found in the environment that we can use for implied bounds.
///
/// Only used for Chalk.
TypeWellFormedFromEnv(Ty<'tcx>),
/// A marker predicate that is always ambiguous. /// A marker predicate that is always ambiguous.
/// Used for coherence to mark opaque types as possibly equal to each other but ambiguous. /// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
Ambiguous, Ambiguous,
@ -1425,7 +1425,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
| PredicateKind::ConstEquate(..) | PredicateKind::ConstEquate(..)
| PredicateKind::Ambiguous | PredicateKind::Ambiguous
| PredicateKind::TypeWellFormedFromEnv(..) => None, | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None,
} }
} }
@ -1446,7 +1446,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
| PredicateKind::ConstEquate(..) | PredicateKind::ConstEquate(..)
| PredicateKind::Ambiguous | PredicateKind::Ambiguous
| PredicateKind::TypeWellFormedFromEnv(..) => None, | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None,
} }
} }
@ -1467,7 +1467,7 @@ impl<'tcx> Predicate<'tcx> {
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..))
| PredicateKind::ConstEquate(..) | PredicateKind::ConstEquate(..)
| PredicateKind::Ambiguous | PredicateKind::Ambiguous
| PredicateKind::TypeWellFormedFromEnv(..) => None, | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None,
} }
} }
@ -1483,7 +1483,7 @@ impl<'tcx> Predicate<'tcx> {
pub fn expect_clause(self) -> Clause<'tcx> { pub fn expect_clause(self) -> Clause<'tcx> {
match self.kind().skip_binder() { match self.kind().skip_binder() {
PredicateKind::Clause(..) => Clause(self.0), PredicateKind::Clause(..) => Clause(self.0),
_ => bug!(), _ => bug!("{self} is not a clause"),
} }
} }
} }

View file

@ -2883,6 +2883,9 @@ define_print_and_forward_display! {
ty::ClauseKind::ConstEvaluatable(ct) => { ty::ClauseKind::ConstEvaluatable(ct) => {
p!("the constant `", print(ct), "` can be evaluated") p!("the constant `", print(ct), "` can be evaluated")
} }
ty::ClauseKind::TypeWellFormedFromEnv(ty) => {
p!("the type `", print(ty), "` is found in the environment")
}
} }
} }
@ -2904,9 +2907,6 @@ define_print_and_forward_display! {
ty::PredicateKind::ConstEquate(c1, c2) => { ty::PredicateKind::ConstEquate(c1, c2) => {
p!("the constant `", print(c1), "` equals `", print(c2), "`") p!("the constant `", print(c1), "` equals `", print(c2), "`")
} }
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
p!("the type `", print(ty), "` is found in the environment")
}
ty::PredicateKind::Ambiguous => p!("ambiguous"), ty::PredicateKind::Ambiguous => p!("ambiguous"),
ty::PredicateKind::AliasRelate(t1, t2, dir) => p!(print(t1), write(" {} ", dir), print(t2)), ty::PredicateKind::AliasRelate(t1, t2, dir) => p!(print(t1), write(" {} ", dir), print(t2)),
} }

View file

@ -189,6 +189,9 @@ impl<'tcx> fmt::Debug for ty::ClauseKind<'tcx> {
ty::ClauseKind::ConstEvaluatable(ct) => { ty::ClauseKind::ConstEvaluatable(ct) => {
write!(f, "ConstEvaluatable({ct:?})") write!(f, "ConstEvaluatable({ct:?})")
} }
ty::ClauseKind::TypeWellFormedFromEnv(ty) => {
write!(f, "TypeWellFormedFromEnv({:?})", ty)
}
} }
} }
} }
@ -206,9 +209,6 @@ impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> {
write!(f, "ClosureKind({:?}, {:?}, {:?})", closure_def_id, closure_substs, kind) write!(f, "ClosureKind({:?}, {:?}, {:?})", closure_def_id, closure_substs, kind)
} }
ty::PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2), ty::PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
write!(f, "TypeWellFormedFromEnv({:?})", ty)
}
ty::PredicateKind::Ambiguous => write!(f, "Ambiguous"), ty::PredicateKind::Ambiguous => write!(f, "Ambiguous"),
ty::PredicateKind::AliasRelate(t1, t2, dir) => { ty::PredicateKind::AliasRelate(t1, t2, dir) => {
write!(f, "AliasRelate({t1:?}, {dir:?}, {t2:?})") write!(f, "AliasRelate({t1:?}, {dir:?}, {t2:?})")

View file

@ -182,6 +182,7 @@ where
} }
ty::ClauseKind::ConstEvaluatable(ct) => ct.visit_with(self), ty::ClauseKind::ConstEvaluatable(ct) => ct.visit_with(self),
ty::ClauseKind::WellFormed(arg) => arg.visit_with(self), ty::ClauseKind::WellFormed(arg) => arg.visit_with(self),
ty::ClauseKind::TypeWellFormedFromEnv(_) => bug!("unexpected clause: {clause}"),
} }
} }

View file

@ -395,7 +395,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
ty::PredicateKind::ConstEquate(_, _) => { ty::PredicateKind::ConstEquate(_, _) => {
bug!("ConstEquate should not be emitted when `-Ztrait-solver=next` is active") bug!("ConstEquate should not be emitted when `-Ztrait-solver=next` is active")
} }
ty::PredicateKind::TypeWellFormedFromEnv(..) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("TypeWellFormedFromEnv is only used for Chalk") bug!("TypeWellFormedFromEnv is only used for Chalk")
} }
ty::PredicateKind::AliasRelate(lhs, rhs, direction) => self ty::PredicateKind::AliasRelate(lhs, rhs, direction) => self

View file

@ -132,8 +132,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
SelectionError::Unimplemented, SelectionError::Unimplemented,
) )
} }
ty::PredicateKind::ConstEquate(..) ty::PredicateKind::ConstEquate(..) => {
| ty::PredicateKind::TypeWellFormedFromEnv(_) => {
bug!("unexpected goal: {goal:?}") bug!("unexpected goal: {goal:?}")
} }
}, },

View file

@ -836,7 +836,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
// FIXME(generic_const_exprs): you can absolutely add this as a where clauses // FIXME(generic_const_exprs): you can absolutely add this as a where clauses
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
| ty::PredicateKind::Coerce(..) => {} | ty::PredicateKind::Coerce(..) => {}
ty::PredicateKind::TypeWellFormedFromEnv(..) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("predicate should only exist in the environment: {bound_predicate:?}") bug!("predicate should only exist in the environment: {bound_predicate:?}")
} }
ty::PredicateKind::Ambiguous => return false, ty::PredicateKind::Ambiguous => return false,

View file

@ -1094,10 +1094,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
ty::PredicateKind::Ambiguous => span_bug!(span, "ambiguous"), ty::PredicateKind::Ambiguous => span_bug!(span, "ambiguous"),
ty::PredicateKind::TypeWellFormedFromEnv(..) => span_bug!( ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
span_bug!(
span, span,
"TypeWellFormedFromEnv predicate should only exist in the environment" "TypeWellFormedFromEnv predicate should only exist in the environment"
), )
}
ty::PredicateKind::AliasRelate(..) => span_bug!( ty::PredicateKind::AliasRelate(..) => span_bug!(
span, span,

View file

@ -366,7 +366,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
ProcessResult::Changed(mk_pending(vec![obligation.with(infcx.tcx, pred)])) ProcessResult::Changed(mk_pending(vec![obligation.with(infcx.tcx, pred)]))
} }
ty::PredicateKind::Ambiguous => ProcessResult::Unchanged, ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
ty::PredicateKind::TypeWellFormedFromEnv(..) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("TypeWellFormedFromEnv is only used for Chalk") bug!("TypeWellFormedFromEnv is only used for Chalk")
} }
ty::PredicateKind::AliasRelate(..) => { ty::PredicateKind::AliasRelate(..) => {
@ -634,7 +634,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
} }
} }
ty::PredicateKind::Ambiguous => ProcessResult::Unchanged, ty::PredicateKind::Ambiguous => ProcessResult::Unchanged,
ty::PredicateKind::TypeWellFormedFromEnv(..) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("TypeWellFormedFromEnv is only used for Chalk") bug!("TypeWellFormedFromEnv is only used for Chalk")
} }
ty::PredicateKind::AliasRelate(..) => { ty::PredicateKind::AliasRelate(..) => {

View file

@ -310,7 +310,8 @@ fn predicate_references_self<'tcx>(
| ty::ClauseKind::TypeOutlives(..) | ty::ClauseKind::TypeOutlives(..)
| ty::ClauseKind::RegionOutlives(..) | ty::ClauseKind::RegionOutlives(..)
// FIXME(generic_const_exprs): this can mention `Self` // FIXME(generic_const_exprs): this can mention `Self`
| ty::ClauseKind::ConstEvaluatable(..) => None, | ty::ClauseKind::ConstEvaluatable(..)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => None,
} }
} }
@ -350,7 +351,8 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
| ty::ClauseKind::Projection(_) | ty::ClauseKind::Projection(_)
| ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::ConstArgHasType(_, _)
| ty::ClauseKind::WellFormed(_) | ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => false, | ty::ClauseKind::ConstEvaluatable(_)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => false,
}) })
} }

View file

@ -134,7 +134,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>(
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {} | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {}
// We need to search through *all* WellFormed predicates // We need to search through *all* WellFormed predicates
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {

View file

@ -967,7 +967,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
} }
} }
ty::PredicateKind::TypeWellFormedFromEnv(..) => { ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("TypeWellFormedFromEnv is only used for chalk") bug!("TypeWellFormedFromEnv is only used for chalk")
} }
ty::PredicateKind::AliasRelate(..) => { ty::PredicateKind::AliasRelate(..) => {

View file

@ -185,7 +185,7 @@ pub fn predicate_obligations<'tcx>(
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::AliasRelate(..) | ty::PredicateKind::AliasRelate(..)
| ty::PredicateKind::TypeWellFormedFromEnv(..) => { | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("We should only wf check where clauses, unexpected predicate: {predicate:?}") bug!("We should only wf check where clauses, unexpected predicate: {predicate:?}")
} }
} }
@ -1005,7 +1005,8 @@ pub(crate) fn required_region_bounds<'tcx>(
| ty::ClauseKind::Projection(_) | ty::ClauseKind::Projection(_)
| ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::ConstArgHasType(_, _)
| ty::ClauseKind::WellFormed(_) | ty::ClauseKind::WellFormed(_)
| ty::ClauseKind::ConstEvaluatable(_) => None, | ty::ClauseKind::ConstEvaluatable(_)
| ty::ClauseKind::TypeWellFormedFromEnv(_) => None,
} }
}) })
.collect() .collect()

View file

@ -93,10 +93,9 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
let (predicate, binders, _named_regions) = let (predicate, binders, _named_regions) =
collect_bound_vars(interner, interner.tcx, predicate.kind()); collect_bound_vars(interner, interner.tcx, predicate.kind());
let consequence = match predicate { let consequence = match predicate {
// TODO: FIXME ty::ClauseKind::TypeWellFormedFromEnv(ty) => {
/*ty::PredicateKind::TypeWellFormedFromEnv(ty) => {
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner))) chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner)))
}*/ }
ty::ClauseKind::Trait(predicate) => chalk_ir::DomainGoal::FromEnv( ty::ClauseKind::Trait(predicate) => chalk_ir::DomainGoal::FromEnv(
chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)), chalk_ir::FromEnv::Trait(predicate.trait_ref.lower_into(interner)),
), ),
@ -223,9 +222,11 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
| ty::PredicateKind::ConstEquate(..) => { | ty::PredicateKind::ConstEquate(..) => {
chalk_ir::GoalData::All(chalk_ir::Goals::empty(interner)) chalk_ir::GoalData::All(chalk_ir::Goals::empty(interner))
} }
ty::PredicateKind::TypeWellFormedFromEnv(ty) => chalk_ir::GoalData::DomainGoal( ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(ty)) => {
chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner))), chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::FromEnv(
), chalk_ir::FromEnv::Ty(ty.lower_into(interner)),
))
}
}; };
chalk_ir::GoalData::Quantified( chalk_ir::GoalData::Quantified(
@ -670,7 +671,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => { | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("unexpected predicate {self}") bug!("unexpected predicate {self}")
} }
}; };
@ -806,7 +807,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => { | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
bug!("unexpected predicate {}", &self) bug!("unexpected predicate {}", &self)
} }
} }

View file

@ -70,6 +70,6 @@ fn not_outlives_predicate(p: ty::Predicate<'_>) -> bool {
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
| ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous | ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => true, | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => true,
} }
} }

View file

@ -427,21 +427,18 @@ fn well_formed_types_in_env(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<ty::Cla
NodeKind::Other => (), NodeKind::Other => (),
} }
let input_clauses = inputs.into_iter().filter_map(|_arg| { let input_clauses = inputs.into_iter().filter_map(|arg| {
// TODO: FIXME match arg.unpack() {
/*match arg.unpack() { ty::GenericArgKind::Type(ty) => {
GenericArgKind::Type(ty) => { Some(ty::ClauseKind::TypeWellFormedFromEnv(ty).to_predicate(tcx))
let binder = Binder::dummy(PredicateKind::TypeWellFormedFromEnv(ty));
Some(tcx.mk_predicate(binder))
} }
// FIXME(eddyb) no WF conditions from lifetimes? // FIXME(eddyb) no WF conditions from lifetimes?
GenericArgKind::Lifetime(_) => None, ty::GenericArgKind::Lifetime(_) => None,
// FIXME(eddyb) support const generics in Chalk // FIXME(eddyb) support const generics in Chalk
GenericArgKind::Const(_) => None, ty::GenericArgKind::Const(_) => None,
}*/ }
None
}); });
tcx.mk_clauses_from_iter(clauses.chain(input_clauses)) tcx.mk_clauses_from_iter(clauses.chain(input_clauses))

View file

@ -1,21 +1,14 @@
error[E0277]: the trait bound `S: Bar` is not satisfied error: the type `S` is not well-formed
--> $DIR/recursive_where_clause_on_type.rs:14:14 --> $DIR/recursive_where_clause_on_type.rs:28:11
| |
LL | impl Foo for S { LL | foo::<S>()
| ^ the trait `Bar` is not implemented for `S` | ^
|
note: required by a bound in `Foo`
--> $DIR/recursive_where_clause_on_type.rs:10:12
|
LL | trait Foo: Bar { }
| ^^^ required by this bound in `Foo`
error: the type `S` is not well-formed error: the type `S` is not well-formed
--> $DIR/recursive_where_clause_on_type.rs:14:14 --> $DIR/recursive_where_clause_on_type.rs:28:5
| |
LL | impl Foo for S { LL | foo::<S>()
| ^ | ^^^^^^^^
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.