@@ -219,6 +219,14 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
219
219
//
220
220
// In that case, the impl-trait is lowered as an additional generic parameter.
221
221
self . with_impl_trait ( ImplTraitContext :: Universal ( self . parent_def ) , |this| {
222
+ if let GenericParamKind :: Const { kw_span : _, ty, default : Some ( ct) } = & param. kind {
223
+ this. visit_ty ( ty) ;
224
+ match ct. value . is_potential_trivial_const_arg ( ) {
225
+ Some ( _) => visit:: walk_anon_const ( this, ct) ,
226
+ None => this. visit_anon_const ( ct) ,
227
+ }
228
+ return ;
229
+ }
222
230
visit:: walk_generic_param ( this, param)
223
231
} ) ;
224
232
}
@@ -241,15 +249,26 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
241
249
}
242
250
}
243
251
252
+ fn visit_generic_arg ( & mut self , generic_arg : & ' a GenericArg ) {
253
+ if let GenericArg :: Const ( anon_ct) = generic_arg {
254
+ if anon_ct. value . is_potential_trivial_const_arg ( ) . is_some ( ) {
255
+ visit:: walk_anon_const ( self , & anon_ct) ;
256
+ return ;
257
+ }
258
+ }
259
+ visit:: walk_generic_arg ( self , generic_arg) ;
260
+ }
261
+
244
262
fn visit_anon_const ( & mut self , constant : & ' a AnonConst ) {
245
263
let def = self . create_def ( constant. id , DefPathData :: AnonConst , constant. value . span ) ;
264
+ debug ! ( ?constant, ?def) ;
246
265
self . with_parent ( def, |this| visit:: walk_anon_const ( this, constant) ) ;
247
266
}
248
267
249
268
fn visit_expr ( & mut self , expr : & ' a Expr ) {
250
- let parent_def = match expr. kind {
269
+ let parent_def = match & expr. kind {
251
270
ExprKind :: MacCall ( ..) => return self . visit_macro_invoc ( expr. id ) ,
252
- ExprKind :: Closure ( ref closure) => {
271
+ ExprKind :: Closure ( closure) => {
253
272
// Async closures desugar to closures inside of closures, so
254
273
// we must create two defs.
255
274
let closure_def = self . create_def ( expr. id , DefPathData :: ClosureExpr , expr. span ) ;
@@ -261,15 +280,30 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
261
280
}
262
281
}
263
282
ExprKind :: Async ( _, _) => self . create_def ( expr. id , DefPathData :: ClosureExpr , expr. span ) ,
283
+ ExprKind :: Repeat ( expr, length) => match length. value . is_potential_trivial_const_arg ( ) {
284
+ Some ( _) => {
285
+ self . visit_expr ( expr) ;
286
+ visit:: walk_anon_const ( self , length) ;
287
+ return ;
288
+ }
289
+ None => self . parent_def ,
290
+ } ,
264
291
_ => self . parent_def ,
265
292
} ;
266
293
267
294
self . with_parent ( parent_def, |this| visit:: walk_expr ( this, expr) ) ;
268
295
}
269
296
270
297
fn visit_ty ( & mut self , ty : & ' a Ty ) {
271
- match ty. kind {
298
+ match & ty. kind {
272
299
TyKind :: MacCall ( ..) => self . visit_macro_invoc ( ty. id ) ,
300
+ TyKind :: Array ( ty, length) => {
301
+ self . visit_ty ( ty) ;
302
+ match length. value . is_potential_trivial_const_arg ( ) {
303
+ Some ( _) => visit:: walk_anon_const ( self , length) ,
304
+ None => self . visit_anon_const ( length) ,
305
+ } ;
306
+ }
273
307
_ => visit:: walk_ty ( self , ty) ,
274
308
}
275
309
}
0 commit comments