@@ -5,7 +5,7 @@ use rustc_infer::infer::{outlives::env::OutlivesEnvironment, TyCtxtInferExt};
55use rustc_lint_defs:: builtin:: REFINING_IMPL_TRAIT ;
66use rustc_middle:: traits:: { ObligationCause , Reveal } ;
77use rustc_middle:: ty:: {
8- self , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable , TypeVisitable , TypeVisitor ,
8+ self , Ty , TyCtxt , TypeFoldable , TypeFolder , TypeSuperVisitable , TypeVisitable , TypeVisitor ,
99} ;
1010use rustc_span:: { Span , DUMMY_SP } ;
1111use rustc_trait_selection:: traits:: {
@@ -178,7 +178,8 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
178178
179179 // For quicker lookup, use an `IndexSet`
180180 // (we don't use one earlier because it's not foldable..)
181- let trait_bounds = FxIndexSet :: from_iter ( trait_bounds) ;
181+ let trait_bounds = FxIndexSet :: from_iter ( trait_bounds. fold_with ( & mut Anonymize { tcx } ) ) ;
182+ let impl_bounds = impl_bounds. fold_with ( & mut Anonymize { tcx } ) ;
182183
183184 // Find any clauses that are present in the impl's RPITITs that are not
184185 // present in the trait's RPITITs. This will trigger on trivial predicates,
@@ -309,3 +310,20 @@ fn type_visibility<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<ty::Visibili
309310 _ => None ,
310311 }
311312}
313+
314+ struct Anonymize < ' tcx > {
315+ tcx : TyCtxt < ' tcx > ,
316+ }
317+
318+ impl < ' tcx > TypeFolder < TyCtxt < ' tcx > > for Anonymize < ' tcx > {
319+ fn interner ( & self ) -> TyCtxt < ' tcx > {
320+ self . tcx
321+ }
322+
323+ fn fold_binder < T > ( & mut self , t : ty:: Binder < ' tcx , T > ) -> ty:: Binder < ' tcx , T >
324+ where
325+ T : TypeFoldable < TyCtxt < ' tcx > > ,
326+ {
327+ self . tcx . anonymize_bound_vars ( t)
328+ }
329+ }
0 commit comments