@@ -15,6 +15,7 @@ use crate::ty::abstract_const::NotConstEvaluatable;
1515use crate :: ty:: { self , AdtKind , Ty } ;
1616use crate :: ty:: { GenericArgsRef , TyCtxt } ;
1717
18+ use hir:: def:: DefKind ;
1819use rustc_data_structures:: sync:: Lrc ;
1920use rustc_errors:: { Applicability , Diag , EmissionGuarantee } ;
2021use rustc_hir as hir;
@@ -1004,7 +1005,7 @@ pub enum CodegenObligationError {
10041005pub enum DefiningAnchor < ' tcx > {
10051006 /// Define opaques which are in-scope of the current item being analyzed.
10061007 /// Also, eagerly replace these opaque types in `replace_opaque_types_with_inference_vars`.
1007- Bind ( & ' tcx [ LocalDefId ] ) ,
1008+ Bind { rpit_and_tait : & ' tcx [ LocalDefId ] , in_assoc_types : & ' tcx [ LocalDefId ] } ,
10081009 /// In contexts where we don't currently know what opaques are allowed to be
10091010 /// defined, such as (old solver) canonical queries, we will simply allow
10101011 /// opaques to be defined, but "bubble" them up in the canonical response or
@@ -1021,6 +1022,19 @@ pub enum DefiningAnchor<'tcx> {
10211022
10221023impl < ' tcx > DefiningAnchor < ' tcx > {
10231024 pub fn bind ( tcx : TyCtxt < ' tcx > , item : LocalDefId ) -> Self {
1024- Self :: Bind ( tcx. opaque_types_defined_by ( item) )
1025+ Self :: Bind {
1026+ rpit_and_tait : tcx. opaque_types_defined_by ( item) ,
1027+ in_assoc_types : match tcx. def_kind ( item) {
1028+ DefKind :: AssocFn | DefKind :: AssocConst | DefKind :: AssocTy => {
1029+ let parent = tcx. local_parent ( item) ;
1030+ if matches ! ( tcx. def_kind( parent) , DefKind :: Impl { of_trait: true } ) {
1031+ tcx. impl_trait_in_assoc_types_defined_by ( item)
1032+ } else {
1033+ & [ ]
1034+ }
1035+ }
1036+ _ => & [ ] ,
1037+ } ,
1038+ }
10251039 }
10261040}
0 commit comments