diff options
Diffstat (limited to 'compiler/rustc_hir_analysis/src/outlives')
-rw-r--r-- | compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs | 12 | ||||
-rw-r--r-- | compiler/rustc_hir_analysis/src/outlives/utils.rs | 30 |
2 files changed, 17 insertions, 25 deletions
diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs index 90c6edb65..925042436 100644 --- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs +++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs @@ -13,9 +13,9 @@ use super::utils::*; /// `global_inferred_outlives`: this is initially the empty map that /// was generated by walking the items in the crate. This will /// now be filled with inferred predicates. -pub(super) fn infer_predicates<'tcx>( - tcx: TyCtxt<'tcx>, -) -> FxHashMap<DefId, ty::EarlyBinder<RequiredPredicates<'tcx>>> { +pub(super) fn infer_predicates( + tcx: TyCtxt<'_>, +) -> FxHashMap<DefId, ty::EarlyBinder<RequiredPredicates<'_>>> { debug!("infer_predicates"); let mut explicit_map = ExplicitPredicatesMap::new(); @@ -139,7 +139,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( if let Some(unsubstituted_predicates) = global_inferred_outlives.get(&def.did()) { for (unsubstituted_predicate, &span) in &unsubstituted_predicates.0 { // `unsubstituted_predicate` is `U: 'b` in the - // example above. So apply the substitution to + // example above. So apply the substitution to // get `T: 'a` (or `predicate`): let predicate = unsubstituted_predicates .rebind(*unsubstituted_predicate) @@ -196,13 +196,13 @@ fn insert_required_predicates_to_be_wf<'tcx>( } } - ty::Projection(obj) => { + ty::Alias(ty::Projection, obj) => { // This corresponds to `<T as Foo<'a>>::Bar`. In this case, we should use the // explicit predicates as well. debug!("Projection"); check_explicit_predicates( tcx, - tcx.parent(obj.item_def_id), + tcx.parent(obj.def_id), obj.substs, required_predicates, explicit_map, diff --git a/compiler/rustc_hir_analysis/src/outlives/utils.rs b/compiler/rustc_hir_analysis/src/outlives/utils.rs index 0409c7081..9459c5f54 100644 --- a/compiler/rustc_hir_analysis/src/outlives/utils.rs +++ b/compiler/rustc_hir_analysis/src/outlives/utils.rs @@ -48,7 +48,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>( // ``` // // Here `outlived_region = 'a` and `kind = &'b - // u32`. Decomposing `&'b u32` into + // u32`. Decomposing `&'b u32` into // components would yield `'b`, and we add the // where clause that `'b: 'a`. insert_outlives_predicate( @@ -71,7 +71,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>( // ``` // // Here `outlived_region = 'a` and `kind = - // Vec<U>`. Decomposing `Vec<U>` into + // Vec<U>`. Decomposing `Vec<U>` into // components would yield `U`, and we add the // where clause that `U: 'a`. let ty: Ty<'tcx> = param_ty.to_ty(tcx); @@ -80,8 +80,8 @@ pub(crate) fn insert_outlives_predicate<'tcx>( .or_insert(span); } - Component::Projection(proj_ty) => { - // This would arise from something like: + Component::Alias(alias_ty) => { + // This would either arise from something like: // // ``` // struct Foo<'a, T: Iterator> { @@ -89,15 +89,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>( // } // ``` // - // Here we want to add an explicit `where <T as Iterator>::Item: 'a`. - let ty: Ty<'tcx> = tcx.mk_projection(proj_ty.item_def_id, proj_ty.substs); - required_predicates - .entry(ty::OutlivesPredicate(ty.into(), outlived_region)) - .or_insert(span); - } - - Component::Opaque(def_id, substs) => { - // This would arise from something like: + // or: // // ```rust // type Opaque<T> = impl Sized; @@ -105,17 +97,17 @@ pub(crate) fn insert_outlives_predicate<'tcx>( // struct Ss<'a, T>(&'a Opaque<T>); // ``` // - // Here we want to have an implied bound `Opaque<T>: 'a` - - let ty = tcx.mk_opaque(def_id, substs); + // Here we want to add an explicit `where <T as Iterator>::Item: 'a` + // or `Opaque<T>: 'a` depending on the alias kind. + let ty = alias_ty.to_ty(tcx); required_predicates .entry(ty::OutlivesPredicate(ty.into(), outlived_region)) .or_insert(span); } - Component::EscapingProjection(_) => { + Component::EscapingAlias(_) => { // As above, but the projection involves - // late-bound regions. Therefore, the WF + // late-bound regions. Therefore, the WF // requirement is not checked in type definition // but at fn call site, so ignore it. // @@ -175,7 +167,7 @@ fn is_free_region(region: Region<'_>) -> bool { // } // // The type above might generate a `T: 'b` bound, but we can - // ignore it. We can't put it on the struct header anyway. + // ignore it. We can't put it on the struct header anyway. ty::ReLateBound(..) => false, // These regions don't appear in types from type declarations: |