@@ -276,7 +276,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
276
276
fn lookup_def_id ( & self , ref_id : NodeId ) -> Option < DefId > {
277
277
self . tcx . expect_def_or_none ( ref_id) . and_then ( |def| {
278
278
match def {
279
- Def :: PrimTy ( ..) | Def :: SelfTy ( ..) => None ,
279
+ Def :: Label ( .. ) | Def :: PrimTy ( ..) | Def :: SelfTy ( ..) | Def :: Err => None ,
280
280
def => Some ( def. def_id ( ) ) ,
281
281
}
282
282
} )
@@ -358,7 +358,10 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
358
358
collector. visit_pat ( & arg. pat ) ;
359
359
let span_utils = self . span . clone ( ) ;
360
360
for & ( id, ref p, ..) in & collector. collected_paths {
361
- let typ = self . tcx . tables ( ) . node_types . get ( & id) . unwrap ( ) . to_string ( ) ;
361
+ let typ = match self . tcx . tables ( ) . node_types . get ( & id) {
362
+ Some ( s) => s. to_string ( ) ,
363
+ None => continue ,
364
+ } ;
362
365
// get the span only for the name of the variable (I hope the path is only ever a
363
366
// variable name, but who knows?)
364
367
let sub_span = span_utils. span_for_last_ident ( p. span ) ;
@@ -988,7 +991,13 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
988
991
match p. node {
989
992
PatKind :: Struct ( ref path, ref fields, _) => {
990
993
visit:: walk_path ( self , path) ;
991
- let adt = self . tcx . tables ( ) . node_id_to_type ( p. id ) . ty_adt_def ( ) . unwrap ( ) ;
994
+ let adt = match self . tcx . tables ( ) . node_id_to_type_opt ( p. id ) {
995
+ Some ( ty) => ty. ty_adt_def ( ) . unwrap ( ) ,
996
+ None => {
997
+ visit:: walk_pat ( self , p) ;
998
+ return ;
999
+ }
1000
+ } ;
992
1001
let variant = adt. variant_of_def ( self . tcx . expect_def ( p. id ) ) ;
993
1002
994
1003
for & Spanned { node : ref field, span } in fields {
@@ -1354,7 +1363,13 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1354
1363
}
1355
1364
ast:: ExprKind :: Struct ( ref path, ref fields, ref base) => {
1356
1365
let hir_expr = self . save_ctxt . tcx . map . expect_expr ( ex. id ) ;
1357
- let adt = self . tcx . tables ( ) . expr_ty ( & hir_expr) . ty_adt_def ( ) . unwrap ( ) ;
1366
+ let adt = match self . tcx . tables ( ) . expr_ty_opt ( & hir_expr) {
1367
+ Some ( ty) => ty. ty_adt_def ( ) . unwrap ( ) ,
1368
+ None => {
1369
+ visit:: walk_expr ( self , ex) ;
1370
+ return ;
1371
+ }
1372
+ } ;
1358
1373
let def = self . tcx . expect_def ( hir_expr. id ) ;
1359
1374
self . process_struct_lit ( ex, path, fields, adt. variant_of_def ( def) , base)
1360
1375
}
@@ -1380,7 +1395,13 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
1380
1395
return ;
1381
1396
}
1382
1397
} ;
1383
- let ty = & self . tcx . tables ( ) . expr_ty_adjusted ( & hir_node) . sty ;
1398
+ let ty = match self . tcx . tables ( ) . expr_ty_adjusted_opt ( & hir_node) {
1399
+ Some ( ty) => & ty. sty ,
1400
+ None => {
1401
+ visit:: walk_expr ( self , ex) ;
1402
+ return ;
1403
+ }
1404
+ } ;
1384
1405
match * ty {
1385
1406
ty:: TyAdt ( def, _) => {
1386
1407
let sub_span = self . span . sub_span_after_token ( ex. span , token:: Dot ) ;
0 commit comments