Auto merge of #85090 - Aaron1011:type-outlives-global, r=matthewjasper,jackh726

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:
bors 2021-07-03 22:42:58 +00:00
commit d34a3a401b
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)
}