@@ -378,8 +378,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
378
378
)
379
379
} ) ;
380
380
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
+ ) ;
383
385
384
386
( trait_ref, lowered_ty)
385
387
} ) ;
@@ -458,7 +460,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
458
460
span : Span ,
459
461
body : Option < & Expr > ,
460
462
) -> ( & ' 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 ) ) ;
462
464
( ty, self . lower_const_body ( span, body) )
463
465
}
464
466
@@ -608,8 +610,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
608
610
hir:: ForeignItemKind :: Fn ( fn_dec, fn_args, generics)
609
611
}
610
612
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 ) ) ;
613
615
hir:: ForeignItemKind :: Static ( ty, * m)
614
616
}
615
617
ForeignItemKind :: TyAlias ( ..) => hir:: ForeignItemKind :: Type ,
@@ -679,11 +681,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
679
681
qself,
680
682
path,
681
683
ParamMode :: ExplicitNamed , // no `'_` in declarations (Issue #61124)
682
- & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
684
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: FieldTy ) ,
683
685
) ;
684
686
self . arena . alloc ( t)
685
687
} else {
686
- self . lower_ty ( & f. ty , & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) )
688
+ self . lower_ty ( & f. ty , & ImplTraitContext :: Disallowed ( ImplTraitPosition :: FieldTy ) )
687
689
} ;
688
690
let hir_id = self . lower_node_id ( f. id ) ;
689
691
self . lower_attrs ( hir_id, & f. attrs ) ;
@@ -708,7 +710,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
708
710
709
711
let ( generics, kind, has_default) = match & i. kind {
710
712
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 ) ) ;
712
715
let body = default. as_ref ( ) . map ( |x| self . lower_const_body ( i. span , Some ( x) ) ) ;
713
716
( hir:: Generics :: empty ( ) , hir:: TraitItemKind :: Const ( ty, body) , body. is_some ( ) )
714
717
}
@@ -746,7 +749,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
746
749
& ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
747
750
|this| {
748
751
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
+ )
750
756
} ) ;
751
757
hir:: TraitItemKind :: Type (
752
758
this. lower_param_bounds (
@@ -805,7 +811,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
805
811
806
812
let ( generics, kind) = match & i. kind {
807
813
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 ) ) ;
809
816
(
810
817
hir:: Generics :: empty ( ) ,
811
818
hir:: ImplItemKind :: Const ( ty, self . lower_const_body ( i. span , expr. as_deref ( ) ) ) ,
@@ -1441,7 +1448,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1441
1448
hir_id : self . next_id ( ) ,
1442
1449
bound_generic_params : self . lower_generic_params ( bound_generic_params) ,
1443
1450
bounded_ty : self
1444
- . lower_ty ( bounded_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1451
+ . lower_ty ( bounded_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1445
1452
bounds : self . arena . alloc_from_iter ( bounds. iter ( ) . map ( |bound| {
1446
1453
self . lower_param_bound (
1447
1454
bound,
@@ -1465,9 +1472,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1465
1472
WherePredicate :: EqPredicate ( WhereEqPredicate { lhs_ty, rhs_ty, span } ) => {
1466
1473
hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1467
1474
lhs_ty : self
1468
- . lower_ty ( lhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1475
+ . lower_ty ( lhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1469
1476
rhs_ty : self
1470
- . lower_ty ( rhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1477
+ . lower_ty ( rhs_ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ) ,
1471
1478
span : self . lower_span ( * span) ,
1472
1479
} )
1473
1480
}
0 commit comments