From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../src/outlives/implicit_infer.rs | 12 ++++----- compiler/rustc_hir_analysis/src/outlives/utils.rs | 30 ++++++++-------------- 2 files changed, 17 insertions(+), 25 deletions(-) (limited to 'compiler/rustc_hir_analysis/src/outlives') 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>> { +pub(super) fn infer_predicates( + tcx: TyCtxt<'_>, +) -> FxHashMap>> { 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 `>::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`. Decomposing `Vec` into + // Vec`. Decomposing `Vec` 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 ::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 = impl Sized; @@ -105,17 +97,17 @@ pub(crate) fn insert_outlives_predicate<'tcx>( // struct Ss<'a, T>(&'a Opaque); // ``` // - // Here we want to have an implied bound `Opaque: 'a` - - let ty = tcx.mk_opaque(def_id, substs); + // Here we want to add an explicit `where ::Item: 'a` + // or `Opaque: '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: -- cgit v1.2.3