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