@@ -7,7 +7,8 @@ use rustc_hir::def::DefKind;
77use rustc_hir:: def_id:: { DefId , LocalDefId } ;
88use rustc_hir:: find_attr;
99use rustc_middle:: ty:: {
10- self , GenericPredicates , ImplTraitInTraitData , Ty , TyCtxt , TypeVisitable , TypeVisitor , Upcast ,
10+ self , GenericPredicates , ImplTraitInTraitData , PredicatePolarity , Ty , TyCtxt , TypeVisitable ,
11+ TypeVisitor , Upcast ,
1112} ;
1213use rustc_middle:: { bug, span_bug} ;
1314use rustc_span:: { DUMMY_SP , Ident , Span } ;
@@ -69,6 +70,19 @@ pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredic
6970 . predicates
7071 . iter ( )
7172 . copied ( )
73+ . filter ( |p| {
74+ if !tcx. features ( ) . move_trait ( ) {
75+ !p. 0 . as_trait_clause ( ) . is_some_and ( |p| {
76+ p. polarity ( ) == PredicatePolarity :: Positive
77+ && matches ! (
78+ tcx. as_lang_item( p. def_id( ) ) ,
79+ Some ( rustc_hir:: LangItem :: Move )
80+ )
81+ } )
82+ } else {
83+ true
84+ }
85+ } )
7286 . chain ( std:: iter:: once ( ( ty:: TraitRef :: identity ( tcx, def_id) . upcast ( tcx) , span) ) ) ,
7387 ) ;
7488 }
@@ -196,19 +210,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
196210 PredicateFilter :: All ,
197211 OverlappingAsssocItemConstraints :: Allowed ,
198212 ) ;
199- icx. lowerer ( ) . add_implicit_sizedness_bounds (
200- & mut bounds,
201- tcx. types . self_param ,
202- self_bounds,
203- ImpliedBoundsContext :: TraitDef ( def_id) ,
204- span,
205- ) ;
206- icx. lowerer ( ) . add_default_traits (
213+ icx. lowerer ( ) . add_implicit_bounds (
207214 & mut bounds,
208215 tcx. types . self_param ,
209216 self_bounds,
210217 ImpliedBoundsContext :: TraitDef ( def_id) ,
211218 span,
219+ true ,
212220 ) ;
213221 predicates. extend ( bounds) ;
214222 }
@@ -235,19 +243,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
235243 let param_ty = icx. lowerer ( ) . lower_ty_param ( param. hir_id ) ;
236244 let mut bounds = Vec :: new ( ) ;
237245 // Implicit bounds are added to type params unless a `?Trait` bound is found
238- icx. lowerer ( ) . add_implicit_sizedness_bounds (
239- & mut bounds,
240- param_ty,
241- & [ ] ,
242- ImpliedBoundsContext :: TyParam ( param. def_id , hir_generics. predicates ) ,
243- param. span ,
244- ) ;
245- icx. lowerer ( ) . add_default_traits (
246+ icx. lowerer ( ) . add_implicit_bounds (
246247 & mut bounds,
247248 param_ty,
248249 & [ ] ,
249250 ImpliedBoundsContext :: TyParam ( param. def_id , hir_generics. predicates ) ,
250251 param. span ,
252+ true ,
251253 ) ;
252254 trace ! ( ?bounds) ;
253255 predicates. extend ( bounds) ;
@@ -688,19 +690,13 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
688690 | PredicateFilter :: SelfOnly
689691 | PredicateFilter :: SelfTraitThatDefines ( _)
690692 | PredicateFilter :: SelfAndAssociatedTypeBounds => {
691- icx. lowerer ( ) . add_implicit_sizedness_bounds (
692- & mut bounds,
693- self_param_ty,
694- superbounds,
695- ImpliedBoundsContext :: TraitDef ( trait_def_id) ,
696- item. span ,
697- ) ;
698- icx. lowerer ( ) . add_default_traits (
693+ icx. lowerer ( ) . add_implicit_bounds (
699694 & mut bounds,
700695 self_param_ty,
701696 superbounds,
702697 ImpliedBoundsContext :: TraitDef ( trait_def_id) ,
703698 item. span ,
699+ true ,
704700 ) ;
705701 }
706702 //`ConstIfConst` is only interested in `[const]` bounds.
@@ -990,19 +986,13 @@ impl<'tcx> ItemCtxt<'tcx> {
990986 match param. kind {
991987 hir:: GenericParamKind :: Type { .. } => {
992988 let param_ty = self . lowerer ( ) . lower_ty_param ( param. hir_id ) ;
993- self . lowerer ( ) . add_implicit_sizedness_bounds (
994- & mut bounds,
995- param_ty,
996- & [ ] ,
997- ImpliedBoundsContext :: TyParam ( param. def_id , hir_generics. predicates ) ,
998- param. span ,
999- ) ;
1000- self . lowerer ( ) . add_default_traits (
989+ self . lowerer ( ) . add_implicit_bounds (
1001990 & mut bounds,
1002991 param_ty,
1003992 & [ ] ,
1004993 ImpliedBoundsContext :: TyParam ( param. def_id , hir_generics. predicates ) ,
1005994 param. span ,
995+ true ,
1006996 ) ;
1007997 }
1008998 hir:: GenericParamKind :: Lifetime { .. }
0 commit comments