@@ -89,26 +89,6 @@ pub(super) struct GenericsGenerationResults<'hir> {
8989 pub ( super ) self_ty_propagation_kind : Option < hir:: DelegationSelfTyPropagationKind > ,
9090}
9191
92- #[ derive( Debug ) ]
93- pub ( super ) enum NonAllocatedGenericArg < ' hir > {
94- Lifetime ( hir:: Lifetime ) ,
95- Type ( hir:: Ty < ' hir , hir:: AmbigArg > ) ,
96- Const ( hir:: ConstArg < ' hir , hir:: AmbigArg > ) ,
97- }
98-
99- impl < ' hir > NonAllocatedGenericArg < ' hir > {
100- pub ( super ) fn allocate_hir_generic_arg (
101- self ,
102- arena : & ' hir hir:: Arena < ' hir > ,
103- ) -> hir:: GenericArg < ' hir > {
104- match self {
105- NonAllocatedGenericArg :: Lifetime ( lt) => hir:: GenericArg :: Lifetime ( arena. alloc ( lt) ) ,
106- NonAllocatedGenericArg :: Type ( ty) => hir:: GenericArg :: Type ( arena. alloc ( ty) ) ,
107- NonAllocatedGenericArg :: Const ( c) => hir:: GenericArg :: Const ( arena. alloc ( c) ) ,
108- }
109- }
110- }
111-
11292pub ( super ) struct DelegationGenericArgsIterator < ' hir > {
11393 index : usize = Default :: default ( ) ,
11494 params : & ' hir [ hir:: GenericParam < ' hir > ] ,
@@ -125,7 +105,7 @@ impl<'hir> DelegationGenericArgsIterator<'hir> {
125105 & mut self ,
126106 ctx : & mut LoweringContext < ' _ , ' hir > ,
127107 hir_id_factory : impl FnOnce ( & mut LoweringContext < ' _ , ' hir > ) -> HirId ,
128- ) -> Option < NonAllocatedGenericArg < ' hir > > {
108+ ) -> Option < hir :: GenericArg < ' hir > > {
129109 let p = loop {
130110 if self . index >= self . params . len ( ) {
131111 return None ;
@@ -144,35 +124,35 @@ impl<'hir> DelegationGenericArgsIterator<'hir> {
144124
145125 let hir_id = hir_id_factory ( ctx) ;
146126
147- match p. kind {
127+ Some ( match p. kind {
148128 hir:: GenericParamKind :: Lifetime { .. } => {
149- Some ( NonAllocatedGenericArg :: Lifetime ( hir:: Lifetime {
129+ hir :: GenericArg :: Lifetime ( ctx . arena . alloc ( hir:: Lifetime {
150130 hir_id,
151131 ident : p. name . ident ( ) ,
152132 kind : hir:: LifetimeKind :: Param ( p. def_id ) ,
153133 source : hir:: LifetimeSource :: Path { angle_brackets : hir:: AngleBrackets :: Full } ,
154134 syntax : hir:: LifetimeSyntax :: ExplicitBound ,
155135 } ) )
156136 }
157- hir:: GenericParamKind :: Type { .. } => Some ( NonAllocatedGenericArg :: Type ( hir:: Ty {
137+ hir:: GenericParamKind :: Type { .. } => hir :: GenericArg :: Type ( ctx . arena . alloc ( hir:: Ty {
158138 hir_id,
159139 span : p. span ,
160140 kind : hir:: TyKind :: Path ( Self :: create_generic_arg_path ( ctx, & p) ) ,
161141 } ) ) ,
162142 hir:: GenericParamKind :: Const { .. } => {
163- Some ( NonAllocatedGenericArg :: Const ( hir:: ConstArg {
143+ hir :: GenericArg :: Const ( ctx . arena . alloc ( hir:: ConstArg {
164144 hir_id,
165145 kind : hir:: ConstArgKind :: Path ( Self :: create_generic_arg_path ( ctx, & p) ) ,
166146 span : p. span ,
167147 } ) )
168148 }
169- }
149+ } )
170150 }
171151
172152 pub ( super ) fn consume_all (
173153 mut self ,
174154 ctx : & mut LoweringContext < ' _ , ' hir > ,
175- ) -> Vec < NonAllocatedGenericArg < ' hir > > {
155+ ) -> Vec < hir :: GenericArg < ' hir > > {
176156 let mut args = vec ! [ ] ;
177157 while let Some ( arg) = self . next ( ctx, |ctx| ctx. next_id ( ) ) {
178158 args. push ( arg) ;
0 commit comments