@@ -967,24 +967,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
967
967
DelimArgs { dspan : args. dspan , delim : args. delim , tokens : args. tokens . flattened ( ) }
968
968
}
969
969
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 (
982
973
& mut self ,
983
- constraint : & AssocConstraint ,
974
+ constraint : & AssocItemConstraint ,
984
975
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.
988
979
let gen_args = if let Some ( gen_args) = & constraint. gen_args {
989
980
let gen_args_ctor = match gen_args {
990
981
GenericArgs :: AngleBracketed ( data) => {
@@ -1000,7 +991,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1000
991
} ;
1001
992
GenericArgsCtor {
1002
993
args : Default :: default ( ) ,
1003
- bindings : & [ ] ,
994
+ constraints : & [ ] ,
1004
995
parenthesized,
1005
996
span : data. inputs_span ,
1006
997
}
@@ -1030,7 +1021,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1030
1021
err. emit ( ) ;
1031
1022
GenericArgsCtor {
1032
1023
args : Default :: default ( ) ,
1033
- bindings : & [ ] ,
1024
+ constraints : & [ ] ,
1034
1025
parenthesized : hir:: GenericArgsParentheses :: ReturnTypeNotation ,
1035
1026
span : data. span ,
1036
1027
}
@@ -1052,14 +1043,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1052
1043
self . arena . alloc ( hir:: GenericArgs :: none ( ) )
1053
1044
} ;
1054
1045
let kind = match & constraint. kind {
1055
- AssocConstraintKind :: Equality { term } => {
1046
+ AssocItemConstraintKind :: Equality { term } => {
1056
1047
let term = match term {
1057
1048
Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
1058
1049
Term :: Const ( c) => self . lower_anon_const ( c) . into ( ) ,
1059
1050
} ;
1060
- hir:: TypeBindingKind :: Equality { term }
1051
+ hir:: AssocItemConstraintKind :: Equality { term }
1061
1052
}
1062
- AssocConstraintKind :: Bound { bounds } => {
1053
+ AssocItemConstraintKind :: Bound { bounds } => {
1063
1054
// Disallow ATB in dyn types
1064
1055
if self . is_in_dyn_type {
1065
1056
let suggestion = match itctx {
@@ -1083,18 +1074,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1083
1074
} ) ;
1084
1075
let err_ty =
1085
1076
& * 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 ( ) }
1087
1078
} else {
1088
- // Desugar `AssocTy: Bounds` into a type binding where the
1079
+ // Desugar `AssocTy: Bounds` into an assoc type binding where the
1089
1080
// later desugars into a trait predicate.
1090
1081
let bounds = self . lower_param_bounds ( bounds, itctx) ;
1091
1082
1092
- hir:: TypeBindingKind :: Constraint { bounds }
1083
+ hir:: AssocItemConstraintKind :: Bound { bounds }
1093
1084
}
1094
1085
}
1095
1086
} ;
1096
1087
1097
- hir:: TypeBinding {
1088
+ hir:: AssocItemConstraint {
1098
1089
hir_id : self . lower_node_id ( constraint. id ) ,
1099
1090
ident : self . lower_ident ( constraint. ident ) ,
1100
1091
gen_args,
@@ -2014,7 +2005,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2014
2005
2015
2006
let bound_args = self . arena . alloc ( hir:: GenericArgs {
2016
2007
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) ] ,
2018
2009
parenthesized : hir:: GenericArgsParentheses :: No ,
2019
2010
span_ext : DUMMY_SP ,
2020
2011
} ) ;
@@ -2587,10 +2578,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2587
2578
}
2588
2579
}
2589
2580
2590
- /// Helper struct for delayed construction of GenericArgs.
2581
+ /// Helper struct for the delayed construction of [`hir:: GenericArgs`] .
2591
2582
struct GenericArgsCtor < ' hir > {
2592
2583
args : SmallVec < [ hir:: GenericArg < ' hir > ; 4 ] > ,
2593
- bindings : & ' hir [ hir:: TypeBinding < ' hir > ] ,
2584
+ constraints : & ' hir [ hir:: AssocItemConstraint < ' hir > ] ,
2594
2585
parenthesized : hir:: GenericArgsParentheses ,
2595
2586
span : Span ,
2596
2587
}
@@ -2670,14 +2661,14 @@ impl<'hir> GenericArgsCtor<'hir> {
2670
2661
2671
2662
fn is_empty ( & self ) -> bool {
2672
2663
self . args . is_empty ( )
2673
- && self . bindings . is_empty ( )
2664
+ && self . constraints . is_empty ( )
2674
2665
&& self . parenthesized == hir:: GenericArgsParentheses :: No
2675
2666
}
2676
2667
2677
2668
fn into_generic_args ( self , this : & LoweringContext < ' _ , ' hir > ) -> & ' hir hir:: GenericArgs < ' hir > {
2678
2669
let ga = hir:: GenericArgs {
2679
2670
args : this. arena . alloc_from_iter ( self . args ) ,
2680
- bindings : self . bindings ,
2671
+ constraints : self . constraints ,
2681
2672
parenthesized : self . parenthesized ,
2682
2673
span_ext : this. lower_span ( self . span ) ,
2683
2674
} ;
0 commit comments