@@ -219,6 +219,14 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
219219 //
220220 // In that case, the impl-trait is lowered as an additional generic parameter.
221221 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+ }
222230 visit:: walk_generic_param ( this, param)
223231 } ) ;
224232 }
@@ -241,15 +249,26 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
241249 }
242250 }
243251
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+
244262 fn visit_anon_const ( & mut self , constant : & ' a AnonConst ) {
245263 let def = self . create_def ( constant. id , DefPathData :: AnonConst , constant. value . span ) ;
264+ debug ! ( ?constant, ?def) ;
246265 self . with_parent ( def, |this| visit:: walk_anon_const ( this, constant) ) ;
247266 }
248267
249268 fn visit_expr ( & mut self , expr : & ' a Expr ) {
250- let parent_def = match expr. kind {
269+ let parent_def = match & expr. kind {
251270 ExprKind :: MacCall ( ..) => return self . visit_macro_invoc ( expr. id ) ,
252- ExprKind :: Closure ( ref closure) => {
271+ ExprKind :: Closure ( closure) => {
253272 // Async closures desugar to closures inside of closures, so
254273 // we must create two defs.
255274 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> {
261280 }
262281 }
263282 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+ } ,
264291 _ => self . parent_def ,
265292 } ;
266293
267294 self . with_parent ( parent_def, |this| visit:: walk_expr ( this, expr) ) ;
268295 }
269296
270297 fn visit_ty ( & mut self , ty : & ' a Ty ) {
271- match ty. kind {
298+ match & ty. kind {
272299 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+ }
273307 _ => visit:: walk_ty ( self , ty) ,
274308 }
275309 }
0 commit comments