@@ -961,24 +961,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
961
961
DelimArgs { dspan : args. dspan , delim : args. delim , tokens : args. tokens . flattened ( ) }
962
962
}
963
963
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 (
976
967
& mut self ,
977
- constraint : & AssocConstraint ,
968
+ constraint : & AssocItemConstraint ,
978
969
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.
982
973
let gen_args = if let Some ( gen_args) = & constraint. gen_args {
983
974
let gen_args_ctor = match gen_args {
984
975
GenericArgs :: AngleBracketed ( data) => {
@@ -994,7 +985,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
994
985
} ;
995
986
GenericArgsCtor {
996
987
args : Default :: default ( ) ,
997
- bindings : & [ ] ,
988
+ constraints : & [ ] ,
998
989
parenthesized,
999
990
span : data. inputs_span ,
1000
991
}
@@ -1024,7 +1015,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1024
1015
err. emit ( ) ;
1025
1016
GenericArgsCtor {
1026
1017
args : Default :: default ( ) ,
1027
- bindings : & [ ] ,
1018
+ constraints : & [ ] ,
1028
1019
parenthesized : hir:: GenericArgsParentheses :: ReturnTypeNotation ,
1029
1020
span : data. span ,
1030
1021
}
@@ -1046,14 +1037,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1046
1037
self . arena . alloc ( hir:: GenericArgs :: none ( ) )
1047
1038
} ;
1048
1039
let kind = match & constraint. kind {
1049
- AssocConstraintKind :: Equality { term } => {
1040
+ AssocItemConstraintKind :: Equality { term } => {
1050
1041
let term = match term {
1051
1042
Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
1052
1043
Term :: Const ( c) => self . lower_anon_const ( c) . into ( ) ,
1053
1044
} ;
1054
- hir:: TypeBindingKind :: Equality { term }
1045
+ hir:: AssocItemConstraintKind :: Equality { term }
1055
1046
}
1056
- AssocConstraintKind :: Bound { bounds } => {
1047
+ AssocItemConstraintKind :: Bound { bounds } => {
1057
1048
// Disallow ATB in dyn types
1058
1049
if self . is_in_dyn_type {
1059
1050
let suggestion = match itctx {
@@ -1077,18 +1068,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1077
1068
} ) ;
1078
1069
let err_ty =
1079
1070
& * 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 ( ) }
1081
1072
} else {
1082
- // Desugar `AssocTy: Bounds` into a type binding where the
1073
+ // Desugar `AssocTy: Bounds` into an assoc type binding where the
1083
1074
// later desugars into a trait predicate.
1084
1075
let bounds = self . lower_param_bounds ( bounds, itctx) ;
1085
1076
1086
- hir:: TypeBindingKind :: Constraint { bounds }
1077
+ hir:: AssocItemConstraintKind :: Bound { bounds }
1087
1078
}
1088
1079
}
1089
1080
} ;
1090
1081
1091
- hir:: TypeBinding {
1082
+ hir:: AssocItemConstraint {
1092
1083
hir_id : self . lower_node_id ( constraint. id ) ,
1093
1084
ident : self . lower_ident ( constraint. ident ) ,
1094
1085
gen_args,
@@ -2008,7 +1999,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2008
1999
2009
2000
let bound_args = self . arena . alloc ( hir:: GenericArgs {
2010
2001
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) ] ,
2012
2003
parenthesized : hir:: GenericArgsParentheses :: No ,
2013
2004
span_ext : DUMMY_SP ,
2014
2005
} ) ;
@@ -2581,10 +2572,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2581
2572
}
2582
2573
}
2583
2574
2584
- /// Helper struct for delayed construction of GenericArgs.
2575
+ /// Helper struct for the delayed construction of [`hir:: GenericArgs`] .
2585
2576
struct GenericArgsCtor < ' hir > {
2586
2577
args : SmallVec < [ hir:: GenericArg < ' hir > ; 4 ] > ,
2587
- bindings : & ' hir [ hir:: TypeBinding < ' hir > ] ,
2578
+ constraints : & ' hir [ hir:: AssocItemConstraint < ' hir > ] ,
2588
2579
parenthesized : hir:: GenericArgsParentheses ,
2589
2580
span : Span ,
2590
2581
}
@@ -2664,14 +2655,14 @@ impl<'hir> GenericArgsCtor<'hir> {
2664
2655
2665
2656
fn is_empty ( & self ) -> bool {
2666
2657
self . args . is_empty ( )
2667
- && self . bindings . is_empty ( )
2658
+ && self . constraints . is_empty ( )
2668
2659
&& self . parenthesized == hir:: GenericArgsParentheses :: No
2669
2660
}
2670
2661
2671
2662
fn into_generic_args ( self , this : & LoweringContext < ' _ , ' hir > ) -> & ' hir hir:: GenericArgs < ' hir > {
2672
2663
let ga = hir:: GenericArgs {
2673
2664
args : this. arena . alloc_from_iter ( self . args ) ,
2674
- bindings : self . bindings ,
2665
+ constraints : self . constraints ,
2675
2666
parenthesized : self . parenthesized ,
2676
2667
span_ext : this. lower_span ( self . span ) ,
2677
2668
} ;
0 commit comments