@@ -84,36 +84,35 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
84
84
}
85
85
}
86
86
87
- fn lookup_and_handle_definition ( & mut self , id : & ast:: NodeId ) {
87
+ fn lookup_and_handle_definition ( & mut self , id : ast:: NodeId ) {
88
88
use ty:: TypeVariants :: { TyEnum , TyStruct } ;
89
89
90
90
// If `bar` is a trait item, make sure to mark Foo as alive in `Foo::bar`
91
- self . tcx . tables . borrow ( ) . item_substs . get ( id)
91
+ self . tcx . tables . borrow ( ) . item_substs . get ( & id)
92
92
. and_then ( |substs| substs. substs . self_ty ( ) )
93
93
. map ( |ty| match ty. sty {
94
94
TyEnum ( tyid, _) | TyStruct ( tyid, _) => self . check_def_id ( tyid. did ) ,
95
95
_ => ( ) ,
96
96
} ) ;
97
97
98
- self . tcx . def_map . borrow ( ) . get ( id) . map ( |def| {
99
- match def. full_def ( ) {
100
- Def :: Const ( _) | Def :: AssociatedConst ( ..) => {
101
- self . check_def_id ( def. def_id ( ) ) ;
102
- }
103
- _ if self . ignore_non_const_paths => ( ) ,
104
- Def :: PrimTy ( _) => ( ) ,
105
- Def :: SelfTy ( ..) => ( ) ,
106
- Def :: Variant ( enum_id, variant_id) => {
107
- self . check_def_id ( enum_id) ;
108
- if !self . ignore_variant_stack . contains ( & variant_id) {
109
- self . check_def_id ( variant_id) ;
110
- }
111
- }
112
- _ => {
113
- self . check_def_id ( def. def_id ( ) ) ;
98
+ let def = self . tcx . expect_def ( id) ;
99
+ match def {
100
+ Def :: Const ( _) | Def :: AssociatedConst ( ..) => {
101
+ self . check_def_id ( def. def_id ( ) ) ;
102
+ }
103
+ _ if self . ignore_non_const_paths => ( ) ,
104
+ Def :: PrimTy ( _) => ( ) ,
105
+ Def :: SelfTy ( ..) => ( ) ,
106
+ Def :: Variant ( enum_id, variant_id) => {
107
+ self . check_def_id ( enum_id) ;
108
+ if !self . ignore_variant_stack . contains ( & variant_id) {
109
+ self . check_def_id ( variant_id) ;
114
110
}
115
111
}
116
- } ) ;
112
+ _ => {
113
+ self . check_def_id ( def. def_id ( ) ) ;
114
+ }
115
+ }
117
116
}
118
117
119
118
fn lookup_and_handle_method ( & mut self , id : ast:: NodeId ) {
@@ -138,10 +137,10 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
138
137
139
138
fn handle_field_pattern_match ( & mut self , lhs : & hir:: Pat ,
140
139
pats : & [ codemap:: Spanned < hir:: FieldPat > ] ) {
141
- let def = self . tcx . def_map . borrow ( ) . get ( & lhs. id ) . unwrap ( ) . full_def ( ) ;
142
- let pat_ty = self . tcx . node_id_to_type ( lhs . id ) ;
143
- let variant = match pat_ty . sty {
144
- ty :: TyStruct ( adt , _ ) | ty :: TyEnum ( adt , _ ) => adt . variant_of_def ( def ) ,
140
+ let variant = match self . tcx . node_id_to_type ( lhs. id ) . sty {
141
+ ty :: TyStruct ( adt , _ ) | ty :: TyEnum ( adt , _ ) => {
142
+ adt . variant_of_def ( self . tcx . expect_def ( lhs . id ) )
143
+ }
145
144
_ => span_bug ! ( lhs. span, "non-ADT in struct pattern" )
146
145
} ;
147
146
for pat in pats {
@@ -272,7 +271,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
272
271
}
273
272
_ if pat_util:: pat_is_const ( & def_map. borrow ( ) , pat) => {
274
273
// it might be the only use of a const
275
- self . lookup_and_handle_definition ( & pat. id )
274
+ self . lookup_and_handle_definition ( pat. id )
276
275
}
277
276
_ => ( )
278
277
}
@@ -283,12 +282,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
283
282
}
284
283
285
284
fn visit_path ( & mut self , path : & hir:: Path , id : ast:: NodeId ) {
286
- self . lookup_and_handle_definition ( & id) ;
285
+ self . lookup_and_handle_definition ( id) ;
287
286
intravisit:: walk_path ( self , path) ;
288
287
}
289
288
290
289
fn visit_path_list_item ( & mut self , path : & hir:: Path , item : & hir:: PathListItem ) {
291
- self . lookup_and_handle_definition ( & item. node . id ( ) ) ;
290
+ self . lookup_and_handle_definition ( item. node . id ( ) ) ;
292
291
intravisit:: walk_path_list_item ( self , path, item) ;
293
292
}
294
293
}
0 commit comments