@@ -378,8 +378,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
378378 )
379379 } ) ;
380380
381- let lowered_ty = this
382- . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
381+ let lowered_ty = this. lower_ty (
382+ ty,
383+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ImplSelf ) ,
384+ ) ;
383385
384386 ( trait_ref, lowered_ty)
385387 } ) ;
@@ -458,7 +460,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
458460 span : Span ,
459461 body : Option < & Expr > ,
460462 ) -> ( & ' hir hir:: Ty < ' hir > , hir:: BodyId ) {
461- let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
463+ let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
462464 ( ty, self . lower_const_body ( span, body) )
463465 }
464466
@@ -608,8 +610,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
608610 hir:: ForeignItemKind :: Fn ( fn_dec, fn_args, generics)
609611 }
610612 ForeignItemKind :: Static ( t, m, _) => {
611- let ty =
612- self . lower_ty ( t, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
613+ let ty = self
614+ . lower_ty ( t, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: StaticTy ) ) ;
613615 hir:: ForeignItemKind :: Static ( ty, * m)
614616 }
615617 ForeignItemKind :: TyAlias ( ..) => hir:: ForeignItemKind :: Type ,
@@ -679,11 +681,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
679681 qself,
680682 path,
681683 ParamMode :: ExplicitNamed , // no `'_` in declarations (Issue #61124)
682- & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
684+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: FieldTy ) ,
683685 ) ;
684686 self . arena . alloc ( t)
685687 } else {
686- self . lower_ty ( & f. ty , & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) )
688+ self . lower_ty ( & f. ty , & ImplTraitContext :: Disallowed ( ImplTraitPosition :: FieldTy ) )
687689 } ;
688690 let hir_id = self . lower_node_id ( f. id ) ;
689691 self . lower_attrs ( hir_id, & f. attrs ) ;
@@ -708,7 +710,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
708710
709711 let ( generics, kind, has_default) = match & i. kind {
710712 AssocItemKind :: Const ( _, ty, default) => {
711- let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
713+ let ty =
714+ self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
712715 let body = default. as_ref ( ) . map ( |x| self . lower_const_body ( i. span , Some ( x) ) ) ;
713716 ( hir:: Generics :: empty ( ) , hir:: TraitItemKind :: Const ( ty, body) , body. is_some ( ) )
714717 }
@@ -746,7 +749,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
746749 & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
747750 |this| {
748751 let ty = ty. as_ref ( ) . map ( |x| {
749- this. lower_ty ( x, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) )
752+ this. lower_ty (
753+ x,
754+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: AssocTy ) ,
755+ )
750756 } ) ;
751757 hir:: TraitItemKind :: Type (
752758 this. lower_param_bounds (
@@ -805,7 +811,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
805811
806812 let ( generics, kind) = match & i. kind {
807813 AssocItemKind :: Const ( _, ty, expr) => {
808- let ty = self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ;
814+ let ty =
815+ self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
809816 (
810817 hir:: Generics :: empty ( ) ,
811818 hir:: ImplItemKind :: Const ( ty, self . lower_const_body ( i. span , expr. as_deref ( ) ) ) ,
@@ -1441,7 +1448,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14411448 hir_id : self . next_id ( ) ,
14421449 bound_generic_params : self . lower_generic_params ( bound_generic_params) ,
14431450 bounded_ty : self
1444- . lower_ty ( bounded_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1451+ . lower_ty ( bounded_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
14451452 bounds : self . arena . alloc_from_iter ( bounds. iter ( ) . map ( |bound| {
14461453 self . lower_param_bound (
14471454 bound,
@@ -1465,9 +1472,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
14651472 WherePredicate :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
14661473 hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
14671474 lhs_ty : self
1468- . lower_ty ( lhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1475+ . lower_ty ( lhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
14691476 rhs_ty : self
1470- . lower_ty ( rhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1477+ . lower_ty ( rhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
14711478 span : self . lower_span ( * span) ,
14721479 } )
14731480 }
0 commit comments