From 1f7cb16fce3f5a334a3b05d168e8c933473e227f Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 8 May 2021 17:06:37 -0400 Subject: 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. --- compiler/rustc_trait_selection/src/traits/select/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_trait_selection') diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index ea5eb2b6866..6cecff4b89d 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -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) } -- cgit 1.4.1-3-g733a5