@@ -276,7 +276,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
276276 fn lookup_def_id ( & self , ref_id : NodeId ) -> Option < DefId > {
277277 self . tcx . expect_def_or_none ( ref_id) . and_then ( |def| {
278278 match def {
279- Def :: PrimTy ( ..) | Def :: SelfTy ( ..) => None ,
279+ Def :: Label ( .. ) | Def :: PrimTy ( ..) | Def :: SelfTy ( ..) | Def :: Err => None ,
280280 def => Some ( def. def_id ( ) ) ,
281281 }
282282 } )
@@ -358,7 +358,10 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
358358 collector. visit_pat ( & arg. pat ) ;
359359 let span_utils = self . span . clone ( ) ;
360360 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+ } ;
362365 // get the span only for the name of the variable (I hope the path is only ever a
363366 // variable name, but who knows?)
364367 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> {
988991 match p. node {
989992 PatKind :: Struct ( ref path, ref fields, _) => {
990993 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+ } ;
9921001 let variant = adt. variant_of_def ( self . tcx . expect_def ( p. id ) ) ;
9931002
9941003 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>
13541363 }
13551364 ast:: ExprKind :: Struct ( ref path, ref fields, ref base) => {
13561365 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+ } ;
13581373 let def = self . tcx . expect_def ( hir_expr. id ) ;
13591374 self . process_struct_lit ( ex, path, fields, adt. variant_of_def ( def) , base)
13601375 }
@@ -1380,7 +1395,13 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D>
13801395 return ;
13811396 }
13821397 } ;
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+ } ;
13841405 match * ty {
13851406 ty:: TyAdt ( def, _) => {
13861407 let sub_span = self . span . sub_span_after_token ( ex. span , token:: Dot ) ;
0 commit comments