@@ -3,8 +3,8 @@ use rustc_hir as hir;
3
3
use rustc_hir:: def:: DefKind ;
4
4
use rustc_index:: bit_set:: BitSet ;
5
5
use rustc_middle:: ty:: {
6
- self , Binder , EarlyBinder , Predicate , PredicateKind , ToPredicate , Ty , TyCtxt ,
7
- TypeSuperVisitable , TypeVisitable , TypeVisitor ,
6
+ self , Binder , EarlyBinder , ImplTraitInTraitData , Predicate , PredicateKind , ToPredicate , Ty ,
7
+ TyCtxt , TypeSuperVisitable , TypeVisitable , TypeVisitor ,
8
8
} ;
9
9
use rustc_session:: config:: TraitSolver ;
10
10
use rustc_span:: def_id:: { DefId , CRATE_DEF_ID } ;
@@ -117,6 +117,15 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
117
117
118
118
/// See `ParamEnv` struct definition for details.
119
119
fn param_env ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> ty:: ParamEnv < ' _ > {
120
+ // When computing the param_env of an RPITIT, copy param_env of the containing function. The
121
+ // synthesized associated type doesn't have extra predicates to assume.
122
+ let def_id =
123
+ if let Some ( ImplTraitInTraitData :: Trait { fn_def_id, .. } ) = tcx. opt_rpitit_info ( def_id) {
124
+ fn_def_id
125
+ } else {
126
+ def_id
127
+ } ;
128
+
120
129
// Compute the bounds on Self and the type parameters.
121
130
let ty:: InstantiatedPredicates { mut predicates, .. } =
122
131
tcx. predicates_of ( def_id) . instantiate_identity ( tcx) ;
0 commit comments