1
- use rustc:: hir;
2
1
use rustc:: hir:: def_id:: { DefId , LOCAL_CRATE } ;
3
2
use rustc:: mir:: * ;
4
3
use rustc:: mir:: visit:: Visitor ;
@@ -184,7 +183,7 @@ fn dump_path(
184
183
let mut file_path = PathBuf :: new ( ) ;
185
184
file_path. push ( Path :: new ( & tcx. sess . opts . debugging_opts . dump_mir_dir ) ) ;
186
185
187
- let item_name = tcx. hir ( )
186
+ let item_name = tcx
188
187
. def_path ( source. def_id )
189
188
. to_filename_friendly_no_crate ( ) ;
190
189
@@ -574,25 +573,26 @@ fn write_mir_sig(
574
573
mir : & Mir < ' _ > ,
575
574
w : & mut dyn Write ,
576
575
) -> io:: Result < ( ) > {
577
- let id = tcx. hir ( ) . as_local_node_id ( src. def_id ) . unwrap ( ) ;
578
- let body_owner_kind = tcx. hir ( ) . body_owner_kind ( id) ;
579
- match ( body_owner_kind, src. promoted ) {
576
+ use rustc:: hir:: def:: Def ;
577
+
578
+ debug ! ( "write_mir_sig: {:?}" , src. def_id) ;
579
+ let descr = tcx. describe_def ( src. def_id ) . unwrap ( ) ;
580
+ match ( descr, src. promoted ) {
580
581
( _, Some ( i) ) => write ! ( w, "{:?} in" , i) ?,
581
- ( hir :: BodyOwnerKind :: Closure , _) |
582
- ( hir :: BodyOwnerKind :: Fn , _) => write ! ( w, "fn " ) ?,
583
- ( hir :: BodyOwnerKind :: Const , _) => write ! ( w, "const " ) ?,
584
- ( hir :: BodyOwnerKind :: Static ( hir :: MutImmutable ) , _) => write ! ( w, "static" ) ?,
585
- ( hir :: BodyOwnerKind :: Static ( hir :: MutMutable ) , _ ) => write ! ( w , "static mut" ) ? ,
582
+ ( Def :: Fn ( _ ) , _) => write ! ( w , "fn" ) ? ,
583
+ ( Def :: Const ( _ ) , _) => write ! ( w, "const " ) ?,
584
+ ( Def :: Static ( _ , /*is_mutbl*/ false ) , _) => write ! ( w, "static " ) ?,
585
+ ( Def :: Static ( _ , /*is_mutbl*/ true ) , _) => write ! ( w, "static mut " ) ?,
586
+ _ => bug ! ( "Unexpected def description {:?}" , descr ) ,
586
587
}
587
588
588
589
item_path:: with_forced_impl_filename_line ( || {
589
590
// see notes on #41697 elsewhere
590
591
write ! ( w, " {}" , tcx. item_path_str( src. def_id) )
591
592
} ) ?;
592
593
593
- match ( body_owner_kind, src. promoted ) {
594
- ( hir:: BodyOwnerKind :: Closure , None ) |
595
- ( hir:: BodyOwnerKind :: Fn , None ) => {
594
+ match ( descr, src. promoted ) {
595
+ ( Def :: Fn ( _) , None ) => {
596
596
write ! ( w, "(" ) ?;
597
597
598
598
// fn argument types.
@@ -605,10 +605,11 @@ fn write_mir_sig(
605
605
606
606
write ! ( w, ") -> {}" , mir. return_ty( ) ) ?;
607
607
}
608
- ( hir :: BodyOwnerKind :: Const , _) | ( hir :: BodyOwnerKind :: Static ( _) , _) | ( _, Some ( _) ) => {
608
+ ( Def :: Const ( _ ) , _) | ( Def :: Static ( _ , _) , _) | ( _, Some ( _) ) => {
609
609
assert_eq ! ( mir. arg_count, 0 ) ;
610
610
write ! ( w, ": {} =" , mir. return_ty( ) ) ?;
611
611
}
612
+ _ => bug ! ( "Unexpected def description {:?}" , descr) ,
612
613
}
613
614
614
615
if let Some ( yield_ty) = mir. yield_ty {
0 commit comments