Return EvaluatedToOk when type in outlives predicate is global

A global type doesn't reference any local regions or types, so it's
guaranteed to outlive any region.
This commit is contained in:
Aaron Hill 2021-05-08 17:06:37 -04:00
parent 6d820866a2
commit 1f7cb16fce
No known key found for this signature in database
GPG key ID: B4087E510E98B164
3 changed files with 24 additions and 16 deletions

View file

@ -492,7 +492,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
None => Ok(EvaluatedToAmbig),
},
ty::PredicateKind::TypeOutlives(..) | ty::PredicateKind::RegionOutlives(..) => {
ty::PredicateKind::TypeOutlives(pred) => {
if pred.0.is_global() {
Ok(EvaluatedToOk)
} else {
Ok(EvaluatedToOkModuloRegions)
}
}
ty::PredicateKind::RegionOutlives(..) => {
// We do not consider region relationships when evaluating trait matches.
Ok(EvaluatedToOkModuloRegions)
}