diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-01-17 05:25:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-17 05:25:22 +0100 |
| commit | 6b49435480ea9a6d8bbd7fd2acf7b3aa6607577c (patch) | |
| tree | 9e80287289ea035cddeb72cbd04c1dbb35c1d912 /compiler/rustc_hir_analysis/src | |
| parent | 9cda9e0ab62467199e09644258618343bd40d52e (diff) | |
| parent | 1ea6862db3830c86355d9179a4cee9410711f68f (diff) | |
| download | rust-6b49435480ea9a6d8bbd7fd2acf7b3aa6607577c.tar.gz rust-6b49435480ea9a6d8bbd7fd2acf7b3aa6607577c.zip | |
Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino
Unify `Opaque`/`Projection` handling in region outlives code They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias` r? types
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/outlives/utils.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_hir_analysis/src/outlives/utils.rs b/compiler/rustc_hir_analysis/src/outlives/utils.rs index b51b740d08e..7d38a6e5f33 100644 --- a/compiler/rustc_hir_analysis/src/outlives/utils.rs +++ b/compiler/rustc_hir_analysis/src/outlives/utils.rs @@ -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(kind, alias) => { + // 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.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,9 +97,9 @@ 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: Ty<'tcx> = tcx.mk_ty(ty::Alias(kind, alias)); required_predicates .entry(ty::OutlivesPredicate(ty.into(), outlived_region)) .or_insert(span); |
