@@ -5,7 +5,7 @@ use rustc_infer::infer::{outlives::env::OutlivesEnvironment, TyCtxtInferExt};
5
5
use rustc_lint_defs:: builtin:: REFINING_IMPL_TRAIT ;
6
6
use rustc_middle:: traits:: { ObligationCause , Reveal } ;
7
7
use rustc_middle:: ty:: {
8
- self , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable , TypeVisitable , TypeVisitor ,
8
+ self , Ty , TyCtxt , TypeFoldable , TypeFolder , TypeSuperVisitable , TypeVisitable , TypeVisitor ,
9
9
} ;
10
10
use rustc_span:: { Span , DUMMY_SP } ;
11
11
use rustc_trait_selection:: traits:: {
@@ -178,7 +178,8 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
178
178
179
179
// For quicker lookup, use an `IndexSet`
180
180
// (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 } ) ;
182
183
183
184
// Find any clauses that are present in the impl's RPITITs that are not
184
185
// 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
309
310
_ => None ,
310
311
}
311
312
}
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