@@ -51,7 +51,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
51
51
tcx : & ' a ty:: ctxt < ' tcx > ,
52
52
live_symbols : Box < HashSet < ast:: NodeId > > ,
53
53
struct_has_extern_repr : bool ,
54
- ignore_paths : bool
54
+ ignore_non_const_paths : bool
55
55
}
56
56
57
57
impl < ' a , ' tcx > MarkSymbolVisitor < ' a , ' tcx > {
@@ -62,7 +62,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
62
62
tcx : tcx,
63
63
live_symbols : box HashSet :: new ( ) ,
64
64
struct_has_extern_repr : false ,
65
- ignore_paths : false
65
+ ignore_non_const_paths : false
66
66
}
67
67
}
68
68
@@ -76,6 +76,10 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
76
76
fn lookup_and_handle_definition ( & mut self , id : & ast:: NodeId ) {
77
77
self . tcx . def_map . borrow ( ) . find ( id) . map ( |def| {
78
78
match def {
79
+ & def:: DefConst ( _) => {
80
+ self . check_def_id ( def. def_id ( ) )
81
+ }
82
+ _ if self . ignore_non_const_paths => ( ) ,
79
83
& def:: DefPrimTy ( _) => ( ) ,
80
84
& def:: DefVariant ( enum_id, variant_id, _) => {
81
85
self . check_def_id ( enum_id) ;
@@ -283,21 +287,19 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
283
287
self . handle_field_pattern_match ( pat, fields. as_slice ( ) ) ;
284
288
}
285
289
_ if pat_util:: pat_is_const ( def_map, pat) => {
286
- // it might be the only use of a static:
290
+ // it might be the only use of a const
287
291
self . lookup_and_handle_definition ( & pat. id )
288
292
}
289
293
_ => ( )
290
294
}
291
295
292
- self . ignore_paths = true ;
296
+ self . ignore_non_const_paths = true ;
293
297
visit:: walk_pat ( self , pat) ;
294
- self . ignore_paths = false ;
298
+ self . ignore_non_const_paths = false ;
295
299
}
296
300
297
301
fn visit_path ( & mut self , path : & ast:: Path , id : ast:: NodeId ) {
298
- if !self . ignore_paths {
299
- self . lookup_and_handle_definition ( & id) ;
300
- }
302
+ self . lookup_and_handle_definition ( & id) ;
301
303
visit:: walk_path ( self , path) ;
302
304
}
303
305
0 commit comments