diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-05-08 17:06:37 -0400 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2021-06-29 19:21:13 -0500 |
| commit | 1f7cb16fce3f5a334a3b05d168e8c933473e227f (patch) | |
| tree | 2ee4cdce4d269f92f58371d71089b7fb2ff75cfd /compiler/rustc_trait_selection/src/traits | |
| parent | 6d820866a27b1949e237be79b9c8c0145fe728b7 (diff) | |
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.
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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) } |
