@@ -961,24 +961,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
961961 DelimArgs { dspan : args. dspan , delim : args. delim , tokens : args. tokens . flattened ( ) }
962962 }
963963
964- /// Given an associated type constraint like one of these:
965- ///
966- /// ```ignore (illustrative)
967- /// T: Iterator<Item: Debug>
968- /// ^^^^^^^^^^^
969- /// T: Iterator<Item = Debug>
970- /// ^^^^^^^^^^^^
971- /// ```
972- ///
973- /// returns a `hir::TypeBinding` representing `Item`.
974- #[ instrument( level = "debug" , skip( self ) ) ]
975- fn lower_assoc_ty_constraint (
964+ /// Lower an associated type constraint.
965+ #[ instrument( level = "debug" , skip_all) ]
966+ fn lower_assoc_item_constraint (
976967 & mut self ,
977- constraint : & AssocConstraint ,
968+ constraint : & AssocItemConstraint ,
978969 itctx : ImplTraitContext ,
979- ) -> hir:: TypeBinding < ' hir > {
980- debug ! ( "lower_assoc_ty_constraint(constraint={:?}, itctx={:?})" , constraint, itctx) ;
981- // lower generic arguments of identifier in constraint
970+ ) -> hir:: AssocItemConstraint < ' hir > {
971+ debug ! ( ? constraint, ? itctx) ;
972+ // Lower the generic arguments for the associated item.
982973 let gen_args = if let Some ( gen_args) = & constraint. gen_args {
983974 let gen_args_ctor = match gen_args {
984975 GenericArgs :: AngleBracketed ( data) => {
@@ -994,7 +985,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
994985 } ;
995986 GenericArgsCtor {
996987 args : Default :: default ( ) ,
997- bindings : & [ ] ,
988+ constraints : & [ ] ,
998989 parenthesized,
999990 span : data. inputs_span ,
1000991 }
@@ -1024,7 +1015,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10241015 err. emit ( ) ;
10251016 GenericArgsCtor {
10261017 args : Default :: default ( ) ,
1027- bindings : & [ ] ,
1018+ constraints : & [ ] ,
10281019 parenthesized : hir:: GenericArgsParentheses :: ReturnTypeNotation ,
10291020 span : data. span ,
10301021 }
@@ -1046,14 +1037,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10461037 self . arena . alloc ( hir:: GenericArgs :: none ( ) )
10471038 } ;
10481039 let kind = match & constraint. kind {
1049- AssocConstraintKind :: Equality { term } => {
1040+ AssocItemConstraintKind :: Equality { term } => {
10501041 let term = match term {
10511042 Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
10521043 Term :: Const ( c) => self . lower_anon_const ( c) . into ( ) ,
10531044 } ;
1054- hir:: TypeBindingKind :: Equality { term }
1045+ hir:: AssocItemConstraintKind :: Equality { term }
10551046 }
1056- AssocConstraintKind :: Bound { bounds } => {
1047+ AssocItemConstraintKind :: Bound { bounds } => {
10571048 // Disallow ATB in dyn types
10581049 if self . is_in_dyn_type {
10591050 let suggestion = match itctx {
@@ -1077,18 +1068,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10771068 } ) ;
10781069 let err_ty =
10791070 & * self . arena . alloc ( self . ty ( constraint. span , hir:: TyKind :: Err ( guar) ) ) ;
1080- hir:: TypeBindingKind :: Equality { term : err_ty. into ( ) }
1071+ hir:: AssocItemConstraintKind :: Equality { term : err_ty. into ( ) }
10811072 } else {
1082- // Desugar `AssocTy: Bounds` into a type binding where the
1073+ // Desugar `AssocTy: Bounds` into an assoc type binding where the
10831074 // later desugars into a trait predicate.
10841075 let bounds = self . lower_param_bounds ( bounds, itctx) ;
10851076
1086- hir:: TypeBindingKind :: Constraint { bounds }
1077+ hir:: AssocItemConstraintKind :: Bound { bounds }
10871078 }
10881079 }
10891080 } ;
10901081
1091- hir:: TypeBinding {
1082+ hir:: AssocItemConstraint {
10921083 hir_id : self . lower_node_id ( constraint. id ) ,
10931084 ident : self . lower_ident ( constraint. ident ) ,
10941085 gen_args,
@@ -2008,7 +1999,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20081999
20092000 let bound_args = self . arena . alloc ( hir:: GenericArgs {
20102001 args : & [ ] ,
2011- bindings : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, opaque_ty_span, output_ty) ] ,
2002+ constraints : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, opaque_ty_span, output_ty) ] ,
20122003 parenthesized : hir:: GenericArgsParentheses :: No ,
20132004 span_ext : DUMMY_SP ,
20142005 } ) ;
@@ -2581,10 +2572,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25812572 }
25822573}
25832574
2584- /// Helper struct for delayed construction of GenericArgs.
2575+ /// Helper struct for the delayed construction of [`hir:: GenericArgs`] .
25852576struct GenericArgsCtor < ' hir > {
25862577 args : SmallVec < [ hir:: GenericArg < ' hir > ; 4 ] > ,
2587- bindings : & ' hir [ hir:: TypeBinding < ' hir > ] ,
2578+ constraints : & ' hir [ hir:: AssocItemConstraint < ' hir > ] ,
25882579 parenthesized : hir:: GenericArgsParentheses ,
25892580 span : Span ,
25902581}
@@ -2664,14 +2655,14 @@ impl<'hir> GenericArgsCtor<'hir> {
26642655
26652656 fn is_empty ( & self ) -> bool {
26662657 self . args . is_empty ( )
2667- && self . bindings . is_empty ( )
2658+ && self . constraints . is_empty ( )
26682659 && self . parenthesized == hir:: GenericArgsParentheses :: No
26692660 }
26702661
26712662 fn into_generic_args ( self , this : & LoweringContext < ' _ , ' hir > ) -> & ' hir hir:: GenericArgs < ' hir > {
26722663 let ga = hir:: GenericArgs {
26732664 args : this. arena . alloc_from_iter ( self . args ) ,
2674- bindings : self . bindings ,
2665+ constraints : self . constraints ,
26752666 parenthesized : self . parenthesized ,
26762667 span_ext : this. lower_span ( self . span ) ,
26772668 } ;
0 commit comments