@@ -967,24 +967,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
967967 DelimArgs { dspan : args. dspan , delim : args. delim , tokens : args. tokens . flattened ( ) }
968968 }
969969
970- /// Given an associated type constraint like one of these:
971- ///
972- /// ```ignore (illustrative)
973- /// T: Iterator<Item: Debug>
974- /// ^^^^^^^^^^^
975- /// T: Iterator<Item = Debug>
976- /// ^^^^^^^^^^^^
977- /// ```
978- ///
979- /// returns a `hir::TypeBinding` representing `Item`.
980- #[ instrument( level = "debug" , skip( self ) ) ]
981- fn lower_assoc_ty_constraint (
970+ /// Lower an associated item constraint.
971+ #[ instrument( level = "debug" , skip_all) ]
972+ fn lower_assoc_item_constraint (
982973 & mut self ,
983- constraint : & AssocConstraint ,
974+ constraint : & AssocItemConstraint ,
984975 itctx : ImplTraitContext ,
985- ) -> hir:: TypeBinding < ' hir > {
986- debug ! ( "lower_assoc_ty_constraint(constraint={:?}, itctx={:?})" , constraint, itctx) ;
987- // lower generic arguments of identifier in constraint
976+ ) -> hir:: AssocItemConstraint < ' hir > {
977+ debug ! ( ? constraint, ? itctx) ;
978+ // Lower the generic arguments for the associated item.
988979 let gen_args = if let Some ( gen_args) = & constraint. gen_args {
989980 let gen_args_ctor = match gen_args {
990981 GenericArgs :: AngleBracketed ( data) => {
@@ -1000,7 +991,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1000991 } ;
1001992 GenericArgsCtor {
1002993 args : Default :: default ( ) ,
1003- bindings : & [ ] ,
994+ constraints : & [ ] ,
1004995 parenthesized,
1005996 span : data. inputs_span ,
1006997 }
@@ -1030,7 +1021,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10301021 err. emit ( ) ;
10311022 GenericArgsCtor {
10321023 args : Default :: default ( ) ,
1033- bindings : & [ ] ,
1024+ constraints : & [ ] ,
10341025 parenthesized : hir:: GenericArgsParentheses :: ReturnTypeNotation ,
10351026 span : data. span ,
10361027 }
@@ -1052,14 +1043,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10521043 self . arena . alloc ( hir:: GenericArgs :: none ( ) )
10531044 } ;
10541045 let kind = match & constraint. kind {
1055- AssocConstraintKind :: Equality { term } => {
1046+ AssocItemConstraintKind :: Equality { term } => {
10561047 let term = match term {
10571048 Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
10581049 Term :: Const ( c) => self . lower_anon_const ( c) . into ( ) ,
10591050 } ;
1060- hir:: TypeBindingKind :: Equality { term }
1051+ hir:: AssocItemConstraintKind :: Equality { term }
10611052 }
1062- AssocConstraintKind :: Bound { bounds } => {
1053+ AssocItemConstraintKind :: Bound { bounds } => {
10631054 // Disallow ATB in dyn types
10641055 if self . is_in_dyn_type {
10651056 let suggestion = match itctx {
@@ -1083,18 +1074,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10831074 } ) ;
10841075 let err_ty =
10851076 & * self . arena . alloc ( self . ty ( constraint. span , hir:: TyKind :: Err ( guar) ) ) ;
1086- hir:: TypeBindingKind :: Equality { term : err_ty. into ( ) }
1077+ hir:: AssocItemConstraintKind :: Equality { term : err_ty. into ( ) }
10871078 } else {
1088- // Desugar `AssocTy: Bounds` into a type binding where the
1079+ // Desugar `AssocTy: Bounds` into an assoc type binding where the
10891080 // later desugars into a trait predicate.
10901081 let bounds = self . lower_param_bounds ( bounds, itctx) ;
10911082
1092- hir:: TypeBindingKind :: Constraint { bounds }
1083+ hir:: AssocItemConstraintKind :: Bound { bounds }
10931084 }
10941085 }
10951086 } ;
10961087
1097- hir:: TypeBinding {
1088+ hir:: AssocItemConstraint {
10981089 hir_id : self . lower_node_id ( constraint. id ) ,
10991090 ident : self . lower_ident ( constraint. ident ) ,
11001091 gen_args,
@@ -2014,7 +2005,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20142005
20152006 let bound_args = self . arena . alloc ( hir:: GenericArgs {
20162007 args : & [ ] ,
2017- bindings : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, opaque_ty_span, output_ty) ] ,
2008+ constraints : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, opaque_ty_span, output_ty) ] ,
20182009 parenthesized : hir:: GenericArgsParentheses :: No ,
20192010 span_ext : DUMMY_SP ,
20202011 } ) ;
@@ -2587,10 +2578,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25872578 }
25882579}
25892580
2590- /// Helper struct for delayed construction of GenericArgs.
2581+ /// Helper struct for the delayed construction of [`hir:: GenericArgs`] .
25912582struct GenericArgsCtor < ' hir > {
25922583 args : SmallVec < [ hir:: GenericArg < ' hir > ; 4 ] > ,
2593- bindings : & ' hir [ hir:: TypeBinding < ' hir > ] ,
2584+ constraints : & ' hir [ hir:: AssocItemConstraint < ' hir > ] ,
25942585 parenthesized : hir:: GenericArgsParentheses ,
25952586 span : Span ,
25962587}
@@ -2670,14 +2661,14 @@ impl<'hir> GenericArgsCtor<'hir> {
26702661
26712662 fn is_empty ( & self ) -> bool {
26722663 self . args . is_empty ( )
2673- && self . bindings . is_empty ( )
2664+ && self . constraints . is_empty ( )
26742665 && self . parenthesized == hir:: GenericArgsParentheses :: No
26752666 }
26762667
26772668 fn into_generic_args ( self , this : & LoweringContext < ' _ , ' hir > ) -> & ' hir hir:: GenericArgs < ' hir > {
26782669 let ga = hir:: GenericArgs {
26792670 args : this. arena . alloc_from_iter ( self . args ) ,
2680- bindings : self . bindings ,
2671+ constraints : self . constraints ,
26812672 parenthesized : self . parenthesized ,
26822673 span_ext : this. lower_span ( self . span ) ,
26832674 } ;
0 commit comments