Use a dummy outlives requirement for where Type:,
(see #53696)
A `WF(Type)` predicate was used previously, which did not play well with implied bounds in chalk.
This commit is contained in:
parent
156a932eef
commit
79b6c41bc2
4 changed files with 20 additions and 20 deletions
|
@ -113,13 +113,14 @@ impl<'tcx> Lower<PolyDomainGoal<'tcx>> for ty::Predicate<'tcx> {
|
||||||
Predicate::RegionOutlives(predicate) => predicate.lower(),
|
Predicate::RegionOutlives(predicate) => predicate.lower(),
|
||||||
Predicate::TypeOutlives(predicate) => predicate.lower(),
|
Predicate::TypeOutlives(predicate) => predicate.lower(),
|
||||||
Predicate::Projection(predicate) => predicate.lower(),
|
Predicate::Projection(predicate) => predicate.lower(),
|
||||||
Predicate::WellFormed(ty) => {
|
|
||||||
ty::Binder::dummy(DomainGoal::WellFormed(WellFormed::Ty(*ty)))
|
Predicate::WellFormed(..) |
|
||||||
|
Predicate::ObjectSafe(..) |
|
||||||
|
Predicate::ClosureKind(..) |
|
||||||
|
Predicate::Subtype(..) |
|
||||||
|
Predicate::ConstEvaluatable(..) => {
|
||||||
|
bug!("unexpected predicate {}", self)
|
||||||
}
|
}
|
||||||
Predicate::ObjectSafe(..)
|
|
||||||
| Predicate::ClosureKind(..)
|
|
||||||
| Predicate::Subtype(..)
|
|
||||||
| Predicate::ConstEvaluatable(..) => unimplemented!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1857,8 +1857,9 @@ fn explicit_predicates_of<'a, 'tcx>(
|
||||||
&hir::WherePredicate::BoundPredicate(ref bound_pred) => {
|
&hir::WherePredicate::BoundPredicate(ref bound_pred) => {
|
||||||
let ty = icx.to_ty(&bound_pred.bounded_ty);
|
let ty = icx.to_ty(&bound_pred.bounded_ty);
|
||||||
|
|
||||||
// Keep the type around in a WF predicate, in case of no bounds.
|
// Keep the type around in a dummy predicate, in case of no bounds.
|
||||||
// That way, `where Ty:` is not a complete noop (see #53696).
|
// That way, `where Ty:` is not a complete noop (see #53696) and `Ty`
|
||||||
|
// is still checked for WF.
|
||||||
if bound_pred.bounds.is_empty() {
|
if bound_pred.bounds.is_empty() {
|
||||||
if let ty::Param(_) = ty.sty {
|
if let ty::Param(_) = ty.sty {
|
||||||
// This is a `where T:`, which can be in the HIR from the
|
// This is a `where T:`, which can be in the HIR from the
|
||||||
|
@ -1869,7 +1870,10 @@ fn explicit_predicates_of<'a, 'tcx>(
|
||||||
// compiler/tooling bugs from not handling WF predicates.
|
// compiler/tooling bugs from not handling WF predicates.
|
||||||
} else {
|
} else {
|
||||||
let span = bound_pred.bounded_ty.span;
|
let span = bound_pred.bounded_ty.span;
|
||||||
predicates.push((ty::Predicate::WellFormed(ty), span));
|
let predicate = ty::OutlivesPredicate(ty, tcx.mk_region(ty::ReEmpty));
|
||||||
|
predicates.push(
|
||||||
|
(ty::Predicate::TypeOutlives(ty::Binder::dummy(predicate)), span)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1325,15 +1325,10 @@ impl<'a> Clean<WherePredicate> for ty::Predicate<'a> {
|
||||||
Predicate::RegionOutlives(ref pred) => pred.clean(cx),
|
Predicate::RegionOutlives(ref pred) => pred.clean(cx),
|
||||||
Predicate::TypeOutlives(ref pred) => pred.clean(cx),
|
Predicate::TypeOutlives(ref pred) => pred.clean(cx),
|
||||||
Predicate::Projection(ref pred) => pred.clean(cx),
|
Predicate::Projection(ref pred) => pred.clean(cx),
|
||||||
Predicate::WellFormed(ty) => {
|
|
||||||
// This comes from `where Ty:` (i.e. no bounds) (see #53696).
|
Predicate::WellFormed(..) |
|
||||||
WherePredicate::BoundPredicate {
|
Predicate::ObjectSafe(..) |
|
||||||
ty: ty.clean(cx),
|
Predicate::ClosureKind(..) |
|
||||||
bounds: vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Predicate::ObjectSafe(_) => panic!("not user writable"),
|
|
||||||
Predicate::ClosureKind(..) => panic!("not user writable"),
|
|
||||||
Predicate::ConstEvaluatable(..) => panic!("not user writable"),
|
Predicate::ConstEvaluatable(..) => panic!("not user writable"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
|
||||||
= note: forall<'a, 'b, Self, T, U> { Implemented(Self: Foo<'a, 'b, T, U>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
= note: forall<'a, 'b, Self, T, U> { Implemented(Self: Foo<'a, 'b, T, U>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
||||||
= note: forall<'a, 'b, Self, T, U> { RegionOutlives('a: 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
= note: forall<'a, 'b, Self, T, U> { RegionOutlives('a: 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
||||||
= note: forall<'a, 'b, Self, T, U> { TypeOutlives(U: 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
= note: forall<'a, 'b, Self, T, U> { TypeOutlives(U: 'b) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
||||||
= note: forall<'a, 'b, Self, T, U> { WellFormed(Self: Foo<'a, 'b, T, U>) :- Implemented(Self: Foo<'a, 'b, T, U>), WellFormed(T: std::borrow::Borrow<U>), TypeOutlives(U: 'b), RegionOutlives('a: 'b), WellFormed(std::boxed::Box<T>). }
|
= note: forall<'a, 'b, Self, T, U> { TypeOutlives(std::boxed::Box<T>: '<empty>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
||||||
= note: forall<'a, 'b, Self, T, U> { WellFormed(std::boxed::Box<T>) :- FromEnv(Self: Foo<'a, 'b, T, U>). }
|
= note: forall<'a, 'b, Self, T, U> { WellFormed(Self: Foo<'a, 'b, T, U>) :- Implemented(Self: Foo<'a, 'b, T, U>), WellFormed(T: std::borrow::Borrow<U>), TypeOutlives(U: 'b), RegionOutlives('a: 'b), TypeOutlives(std::boxed::Box<T>: '<empty>). }
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue