about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/impl_wf_check.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-06-14 05:20:31 +0000
committerMichael Goulet <michael@errs.io>2023-06-14 05:20:31 +0000
commitbc78d0cbf1efb76fa6d7c80bb029a4b6d9af92c3 (patch)
tree11cfcd0d5104f741f7ba8e5b68a72bbe23b6cab5 /compiler/rustc_hir_analysis/src/impl_wf_check.rs
parent6330daade9766bbf896495898c2347dc3be6da17 (diff)
downloadrust-bc78d0cbf1efb76fa6d7c80bb029a4b6d9af92c3.tar.gz
rust-bc78d0cbf1efb76fa6d7c80bb029a4b6d9af92c3.zip
Error on unconstrained lifetime in RPITIT
Diffstat (limited to 'compiler/rustc_hir_analysis/src/impl_wf_check.rs')
-rw-r--r--compiler/rustc_hir_analysis/src/impl_wf_check.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs
index 612d4ff3df8..5526dd4b007 100644
--- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs
+++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs
@@ -106,10 +106,23 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
                     if item.defaultness(tcx).has_value() {
                         cgp::parameters_for(&tcx.type_of(def_id).subst_identity(), true)
                     } else {
-                        Vec::new()
+                        vec![]
                     }
                 }
-                ty::AssocKind::Fn | ty::AssocKind::Const => Vec::new(),
+                ty::AssocKind::Fn => {
+                    if !tcx.lower_impl_trait_in_trait_to_assoc_ty()
+                        && item.defaultness(tcx).has_value()
+                        && tcx.impl_method_has_trait_impl_trait_tys(item.def_id)
+                        && let Ok(table) = tcx.collect_return_position_impl_trait_in_trait_tys(def_id)
+                    {
+                        table.values().copied().flat_map(|ty| {
+                            cgp::parameters_for(&ty.subst_identity(), true)
+                        }).collect()
+                    } else {
+                        vec![]
+                    }
+                }
+                ty::AssocKind::Const => vec![],
             }
         })
         .collect();