|
1 | 1 | use rustc_infer::infer::outlives::components::{push_outlives_components, Component}; |
2 | 2 | use rustc_middle::ty::subst::{GenericArg, GenericArgKind}; |
3 | | -use rustc_middle::ty::{self, EarlyBinder, Region, Ty, TyCtxt}; |
| 3 | +use rustc_middle::ty::{self, Region, Ty, TyCtxt}; |
4 | 4 | use rustc_span::Span; |
5 | 5 | use smallvec::smallvec; |
6 | 6 | use std::collections::BTreeMap; |
@@ -97,36 +97,20 @@ pub(crate) fn insert_outlives_predicate<'tcx>( |
97 | 97 | } |
98 | 98 |
|
99 | 99 | Component::Opaque(def_id, substs) => { |
100 | | - for predicate in tcx.item_bounds(def_id) { |
101 | | - let predicate = EarlyBinder(predicate).subst(tcx, substs); |
102 | | - // FIXME(oli-obk): fishy skip-binder |
103 | | - match predicate.kind().skip_binder() { |
104 | | - ty::PredicateKind::Trait(tp) => { |
105 | | - for subst in tp.trait_ref.substs { |
106 | | - insert_outlives_predicate( |
107 | | - tcx, |
108 | | - subst, |
109 | | - outlived_region, |
110 | | - span, |
111 | | - required_predicates, |
112 | | - ) |
113 | | - } |
114 | | - } |
115 | | - ty::PredicateKind::RegionOutlives(_) |
116 | | - | ty::PredicateKind::TypeOutlives(_) |
117 | | - | ty::PredicateKind::Projection(_) |
118 | | - | ty::PredicateKind::WellFormed(_) |
119 | | - | ty::PredicateKind::ObjectSafe(_) |
120 | | - | ty::PredicateKind::ClosureKind(_, _, _) |
121 | | - | ty::PredicateKind::Subtype(_) |
122 | | - | ty::PredicateKind::Coerce(_) |
123 | | - | ty::PredicateKind::ConstEvaluatable(_) |
124 | | - | ty::PredicateKind::ConstEquate(_, _) |
125 | | - | ty::PredicateKind::TypeWellFormedFromEnv(_) => { |
126 | | - todo!("{:#?}", predicate) |
127 | | - } |
128 | | - } |
129 | | - } |
| 100 | + // This would arise from something like: |
| 101 | + // |
| 102 | + // ```rust |
| 103 | + // type Opaque<T> = impl Sized; |
| 104 | + // fn defining<T>() -> Opaque<T> {} |
| 105 | + // struct Ss<'a, T>(&'a Opaque<T>); |
| 106 | + // ``` |
| 107 | + // |
| 108 | + // Here we want to require an explicit `where Opaque<T>: 'a` |
| 109 | + |
| 110 | + let ty = tcx.mk_opaque(def_id, substs); |
| 111 | + required_predicates |
| 112 | + .entry(ty::OutlivesPredicate(ty.into(), outlived_region)) |
| 113 | + .or_insert(span); |
130 | 114 | } |
131 | 115 |
|
132 | 116 | Component::EscapingProjection(_) => { |
|
0 commit comments