@@ -51,7 +51,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
5151 tcx : & ' a ty:: ctxt < ' tcx > ,
5252 live_symbols : Box < HashSet < ast:: NodeId > > ,
5353 struct_has_extern_repr : bool ,
54- ignore_paths : bool
54+ ignore_non_const_paths : bool
5555}
5656
5757impl < ' a , ' tcx > MarkSymbolVisitor < ' a , ' tcx > {
@@ -62,7 +62,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
6262 tcx : tcx,
6363 live_symbols : box HashSet :: new ( ) ,
6464 struct_has_extern_repr : false ,
65- ignore_paths : false
65+ ignore_non_const_paths : false
6666 }
6767 }
6868
@@ -76,6 +76,10 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
7676 fn lookup_and_handle_definition ( & mut self , id : & ast:: NodeId ) {
7777 self . tcx . def_map . borrow ( ) . find ( id) . map ( |def| {
7878 match def {
79+ & def:: DefConst ( _) => {
80+ self . check_def_id ( def. def_id ( ) )
81+ }
82+ _ if self . ignore_non_const_paths => ( ) ,
7983 & def:: DefPrimTy ( _) => ( ) ,
8084 & def:: DefVariant ( enum_id, variant_id, _) => {
8185 self . check_def_id ( enum_id) ;
@@ -283,21 +287,19 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
283287 self . handle_field_pattern_match ( pat, fields. as_slice ( ) ) ;
284288 }
285289 _ 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
287291 self . lookup_and_handle_definition ( & pat. id )
288292 }
289293 _ => ( )
290294 }
291295
292- self . ignore_paths = true ;
296+ self . ignore_non_const_paths = true ;
293297 visit:: walk_pat ( self , pat) ;
294- self . ignore_paths = false ;
298+ self . ignore_non_const_paths = false ;
295299 }
296300
297301 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) ;
301303 visit:: walk_path ( self , path) ;
302304 }
303305
0 commit comments