11use rustc_data_structures:: graph:: iterate:: {
22 ControlFlow , NodeStatus , TriColorDepthFirstSearch , TriColorVisitor ,
33} ;
4- use rustc_hir:: def_id:: DefId ;
4+ use rustc_hir:: def_id:: LocalDefId ;
55use rustc_hir:: intravisit:: FnKind ;
66use rustc_middle:: hir:: map:: blocks:: FnLikeNode ;
77use rustc_middle:: mir:: { BasicBlock , Body , Operand , TerminatorKind } ;
@@ -10,8 +10,8 @@ use rustc_middle::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
1010use rustc_session:: lint:: builtin:: UNCONDITIONAL_RECURSION ;
1111use rustc_span:: Span ;
1212
13- crate fn check < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , def_id : DefId ) {
14- let hir_id = tcx. hir ( ) . as_local_hir_id ( def_id. expect_local ( ) ) ;
13+ crate fn check < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & Body < ' tcx > , def_id : LocalDefId ) {
14+ let hir_id = tcx. hir ( ) . as_local_hir_id ( def_id) ;
1515
1616 if let Some ( fn_like_node) = FnLikeNode :: from_node ( tcx. hir ( ) . get ( hir_id) ) {
1717 if let FnKind :: Closure ( _) = fn_like_node. kind ( ) {
@@ -20,12 +20,12 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) {
2020 }
2121
2222 // If this is trait/impl method, extract the trait's substs.
23- let trait_substs = match tcx. opt_associated_item ( def_id) {
23+ let trait_substs = match tcx. opt_associated_item ( def_id. to_def_id ( ) ) {
2424 Some ( AssocItem {
2525 container : AssocItemContainer :: TraitContainer ( trait_def_id) , ..
2626 } ) => {
2727 let trait_substs_count = tcx. generics_of ( trait_def_id) . count ( ) ;
28- & InternalSubsts :: identity_for_item ( tcx, def_id) [ ..trait_substs_count]
28+ & InternalSubsts :: identity_for_item ( tcx, def_id. to_def_id ( ) ) [ ..trait_substs_count]
2929 }
3030 _ => & [ ] ,
3131 } ;
@@ -37,7 +37,7 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) {
3737
3838 vis. reachable_recursive_calls . sort ( ) ;
3939
40- let hir_id = tcx. hir ( ) . as_local_hir_id ( def_id. expect_local ( ) ) ;
40+ let hir_id = tcx. hir ( ) . as_local_hir_id ( def_id) ;
4141 let sp = tcx. sess . source_map ( ) . guess_head_span ( tcx. hir ( ) . span ( hir_id) ) ;
4242 tcx. struct_span_lint_hir ( UNCONDITIONAL_RECURSION , hir_id, sp, |lint| {
4343 let mut db = lint. build ( "function cannot return without recursing" ) ;
@@ -57,7 +57,7 @@ struct NonRecursive;
5757struct Search < ' mir , ' tcx > {
5858 tcx : TyCtxt < ' tcx > ,
5959 body : & ' mir Body < ' tcx > ,
60- def_id : DefId ,
60+ def_id : LocalDefId ,
6161 trait_substs : & ' tcx [ GenericArg < ' tcx > ] ,
6262
6363 reachable_recursive_calls : Vec < Span > ,
@@ -84,7 +84,8 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> {
8484 // calling into an entirely different method (for example, a call from the default
8585 // method in the trait to `<A as Trait<B>>::method`, where `A` and/or `B` are
8686 // specific types).
87- return call_fn_id == def_id && & call_substs[ ..trait_substs. len ( ) ] == trait_substs;
87+ return call_fn_id == def_id. to_def_id ( )
88+ && & call_substs[ ..trait_substs. len ( ) ] == trait_substs;
8889 }
8990
9091 false
0 commit comments