99
1010use rustc_errors:: struct_span_err;
1111use rustc_hir as hir;
12- use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId , LOCAL_CRATE } ;
12+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1313use rustc_hir:: itemlikevisit:: ItemLikeVisitor ;
1414use rustc_middle:: ty:: { self , CrateInherentImpls , TyCtxt } ;
1515
1616use rustc_span:: Span ;
1717
1818/// On-demand query: yields a map containing all types mapped to their inherent impls.
19- pub fn crate_inherent_impls ( tcx : TyCtxt < ' _ > , crate_num : CrateNum ) -> CrateInherentImpls {
20- assert_eq ! ( crate_num, LOCAL_CRATE ) ;
21-
19+ pub fn crate_inherent_impls ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> CrateInherentImpls {
2220 let krate = tcx. hir ( ) . krate ( ) ;
2321 let mut collect = InherentCollect { tcx, impls_map : Default :: default ( ) } ;
2422 krate. visit_all_item_likes ( & mut collect) ;
@@ -27,9 +25,9 @@ pub fn crate_inherent_impls(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateInhere
2725
2826/// On-demand query: yields a vector of the inherent impls for a specific type.
2927pub fn inherent_impls ( tcx : TyCtxt < ' _ > , ty_def_id : DefId ) -> & [ DefId ] {
30- assert ! ( ty_def_id. is_local ( ) ) ;
28+ let ty_def_id = ty_def_id . expect_local ( ) ;
3129
32- let crate_map = tcx. crate_inherent_impls ( ty_def_id . krate ) ;
30+ let crate_map = tcx. crate_inherent_impls ( ( ) ) ;
3331 match crate_map. inherent_impls . get ( & ty_def_id) {
3432 Some ( v) => & v[ ..] ,
3533 None => & [ ] ,
@@ -364,7 +362,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
364362
365363impl InherentCollect < ' tcx > {
366364 fn check_def_id ( & mut self , item : & hir:: Item < ' _ > , def_id : DefId ) {
367- if def_id. is_local ( ) {
365+ if let Some ( def_id) = def_id . as_local ( ) {
368366 // Add the implementation to the mapping from implementation to base
369367 // type def ID, if there is a base type for this implementation and
370368 // the implementation does not have any associated traits.
0 commit comments