@@ -8,7 +8,7 @@ use rustc_attr as attr;
88use rustc_errors:: { ErrorGuaranteed , MultiSpan } ;
99use rustc_hir as hir;
1010use rustc_hir:: def:: { CtorKind , DefKind } ;
11- use rustc_hir:: def_id:: { DefId , LocalDefId , LocalModDefId } ;
11+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1212use rustc_hir:: Node ;
1313use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
1414use rustc_infer:: infer:: { RegionVariableOrigin , TyCtxtInferExt } ;
@@ -201,8 +201,8 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
201201
202202/// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo`
203203/// projections that would result in "inheriting lifetimes".
204- fn check_opaque ( tcx : TyCtxt < ' _ > , id : hir :: ItemId ) {
205- let item = tcx. hir ( ) . item ( id ) ;
204+ fn check_opaque ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
205+ let item = tcx. hir ( ) . expect_item ( def_id ) ;
206206 let hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy { origin, .. } ) = item. kind else {
207207 tcx. sess . delay_span_bug ( item. span , "expected opaque item" ) ;
208208 return ;
@@ -443,40 +443,35 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
443443 }
444444}
445445
446- fn check_item_type ( tcx : TyCtxt < ' _ > , id : hir:: ItemId ) {
447- debug ! (
448- "check_item_type(it.def_id={:?}, it.name={})" ,
449- id. owner_id,
450- tcx. def_path_str( id. owner_id)
451- ) ;
446+ pub ( crate ) fn check_item_type ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
452447 let _indenter = indenter ( ) ;
453- match tcx. def_kind ( id . owner_id ) {
448+ match tcx. def_kind ( def_id ) {
454449 DefKind :: Static ( ..) => {
455- tcx. ensure ( ) . typeck ( id . owner_id . def_id ) ;
456- maybe_check_static_with_link_section ( tcx, id . owner_id . def_id ) ;
457- check_static_inhabited ( tcx, id . owner_id . def_id ) ;
458- check_static_linkage ( tcx, id . owner_id . def_id ) ;
450+ tcx. ensure ( ) . typeck ( def_id) ;
451+ maybe_check_static_with_link_section ( tcx, def_id) ;
452+ check_static_inhabited ( tcx, def_id) ;
453+ check_static_linkage ( tcx, def_id) ;
459454 }
460455 DefKind :: Const => {
461- tcx. ensure ( ) . typeck ( id . owner_id . def_id ) ;
456+ tcx. ensure ( ) . typeck ( def_id) ;
462457 }
463458 DefKind :: Enum => {
464- check_enum ( tcx, id . owner_id . def_id ) ;
459+ check_enum ( tcx, def_id) ;
465460 }
466461 DefKind :: Fn => { } // entirely within check_item_body
467462 DefKind :: Impl { of_trait } => {
468- if of_trait && let Some ( impl_trait_ref) = tcx. impl_trait_ref ( id . owner_id ) {
463+ if of_trait && let Some ( impl_trait_ref) = tcx. impl_trait_ref ( def_id ) {
469464 check_impl_items_against_trait (
470465 tcx,
471- id . owner_id . def_id ,
466+ def_id,
472467 impl_trait_ref. instantiate_identity ( ) ,
473468 ) ;
474- check_on_unimplemented ( tcx, id ) ;
469+ check_on_unimplemented ( tcx, def_id ) ;
475470 }
476471 }
477472 DefKind :: Trait => {
478- let assoc_items = tcx. associated_items ( id . owner_id ) ;
479- check_on_unimplemented ( tcx, id ) ;
473+ let assoc_items = tcx. associated_items ( def_id ) ;
474+ check_on_unimplemented ( tcx, def_id ) ;
480475
481476 for & assoc_item in assoc_items. in_definition_order ( ) {
482477 match assoc_item. kind {
@@ -485,43 +480,43 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
485480 fn_maybe_err ( tcx, assoc_item. ident ( tcx) . span , abi) ;
486481 }
487482 ty:: AssocKind :: Type if assoc_item. defaultness ( tcx) . has_value ( ) => {
488- let trait_args = GenericArgs :: identity_for_item ( tcx, id . owner_id ) ;
483+ let trait_args = GenericArgs :: identity_for_item ( tcx, def_id ) ;
489484 let _: Result < _ , rustc_errors:: ErrorGuaranteed > = check_type_bounds (
490485 tcx,
491486 assoc_item,
492487 assoc_item,
493- ty:: TraitRef :: new ( tcx, id . owner_id . to_def_id ( ) , trait_args) ,
488+ ty:: TraitRef :: new ( tcx, def_id . to_def_id ( ) , trait_args) ,
494489 ) ;
495490 }
496491 _ => { }
497492 }
498493 }
499494 }
500495 DefKind :: Struct => {
501- check_struct ( tcx, id . owner_id . def_id ) ;
496+ check_struct ( tcx, def_id) ;
502497 }
503498 DefKind :: Union => {
504- check_union ( tcx, id . owner_id . def_id ) ;
499+ check_union ( tcx, def_id) ;
505500 }
506501 DefKind :: OpaqueTy => {
507- let origin = tcx. opaque_type_origin ( id . owner_id . def_id ) ;
502+ let origin = tcx. opaque_type_origin ( def_id) ;
508503 if let hir:: OpaqueTyOrigin :: FnReturn ( fn_def_id)
509504 | hir:: OpaqueTyOrigin :: AsyncFn ( fn_def_id) = origin
510505 && let hir:: Node :: TraitItem ( trait_item) = tcx. hir ( ) . get_by_def_id ( fn_def_id)
511506 && let ( _, hir:: TraitFn :: Required ( ..) ) = trait_item. expect_fn ( )
512507 {
513508 // Skip opaques from RPIT in traits with no default body.
514509 } else {
515- check_opaque ( tcx, id ) ;
510+ check_opaque ( tcx, def_id ) ;
516511 }
517512 }
518513 DefKind :: TyAlias => {
519- let pty_ty = tcx. type_of ( id . owner_id ) . instantiate_identity ( ) ;
520- let generics = tcx. generics_of ( id . owner_id ) ;
514+ let pty_ty = tcx. type_of ( def_id ) . instantiate_identity ( ) ;
515+ let generics = tcx. generics_of ( def_id ) ;
521516 check_type_params_are_used ( tcx, & generics, pty_ty) ;
522517 }
523518 DefKind :: ForeignMod => {
524- let it = tcx. hir ( ) . item ( id ) ;
519+ let it = tcx. hir ( ) . expect_item ( def_id ) ;
525520 let hir:: ItemKind :: ForeignMod { abi, items } = it. kind else {
526521 return ;
527522 } ;
@@ -592,19 +587,19 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
592587 }
593588 }
594589 DefKind :: GlobalAsm => {
595- let it = tcx. hir ( ) . item ( id ) ;
590+ let it = tcx. hir ( ) . expect_item ( def_id ) ;
596591 let hir:: ItemKind :: GlobalAsm ( asm) = it. kind else {
597592 span_bug ! ( it. span, "DefKind::GlobalAsm but got {:#?}" , it)
598593 } ;
599- InlineAsmCtxt :: new_global_asm ( tcx) . check_asm ( asm, id . owner_id . def_id ) ;
594+ InlineAsmCtxt :: new_global_asm ( tcx) . check_asm ( asm, def_id) ;
600595 }
601596 _ => { }
602597 }
603598}
604599
605- pub ( super ) fn check_on_unimplemented ( tcx : TyCtxt < ' _ > , item : hir :: ItemId ) {
600+ pub ( super ) fn check_on_unimplemented ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) {
606601 // an error would be reported if this fails.
607- let _ = OnUnimplementedDirective :: of_item ( tcx, item . owner_id . to_def_id ( ) ) ;
602+ let _ = OnUnimplementedDirective :: of_item ( tcx, def_id . to_def_id ( ) ) ;
608603}
609604
610605pub ( super ) fn check_specialization_validity < ' tcx > (
@@ -1314,16 +1309,6 @@ pub(super) fn check_type_params_are_used<'tcx>(
13141309 }
13151310}
13161311
1317- pub ( super ) fn check_mod_item_types ( tcx : TyCtxt < ' _ > , module_def_id : LocalModDefId ) {
1318- let module = tcx. hir_module_items ( module_def_id) ;
1319- for id in module. items ( ) {
1320- check_item_type ( tcx, id) ;
1321- }
1322- if module_def_id == LocalModDefId :: CRATE_DEF_ID {
1323- super :: entry:: check_for_entry_fn ( tcx) ;
1324- }
1325- }
1326-
13271312fn async_opaque_type_cycle_error ( tcx : TyCtxt < ' _ > , span : Span ) -> ErrorGuaranteed {
13281313 struct_span_err ! ( tcx. sess, span, E0733 , "recursion in an `async fn` requires boxing" )
13291314 . span_label ( span, "recursive `async fn`" )
0 commit comments