@@ -142,23 +142,23 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
142
142
}
143
143
}
144
144
hir:: ItemKind :: Fn ( ref sig, ..) => {
145
- check_item_fn ( tcx, item. hir_id ( ) , item. ident , item. span , sig. decl ) ;
145
+ check_item_fn ( tcx, item. def_id , item. ident , item. span , sig. decl ) ;
146
146
}
147
147
hir:: ItemKind :: Static ( ty, ..) => {
148
- check_item_type ( tcx, item. hir_id ( ) , ty. span , false ) ;
148
+ check_item_type ( tcx, item. def_id , ty. span , false ) ;
149
149
}
150
150
hir:: ItemKind :: Const ( ty, ..) => {
151
- check_item_type ( tcx, item. hir_id ( ) , ty. span , false ) ;
151
+ check_item_type ( tcx, item. def_id , ty. span , false ) ;
152
152
}
153
153
hir:: ItemKind :: ForeignMod { items, .. } => {
154
154
for it in items. iter ( ) {
155
155
let it = tcx. hir ( ) . foreign_item ( it. id ) ;
156
156
match it. kind {
157
157
hir:: ForeignItemKind :: Fn ( decl, ..) => {
158
- check_item_fn ( tcx, it. hir_id ( ) , it. ident , it. span , decl)
158
+ check_item_fn ( tcx, it. def_id , it. ident , it. span , decl)
159
159
}
160
160
hir:: ForeignItemKind :: Static ( ty, ..) => {
161
- check_item_type ( tcx, it. hir_id ( ) , ty. span , true )
161
+ check_item_type ( tcx, it. def_id , ty. span , true )
162
162
}
163
163
hir:: ForeignItemKind :: Type => ( ) ,
164
164
}
@@ -199,7 +199,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
199
199
_ => ( None , trait_item. span ) ,
200
200
} ;
201
201
check_object_unsafe_self_trait_by_name ( tcx, trait_item) ;
202
- check_associated_item ( tcx, trait_item. hir_id ( ) , span, method_sig) ;
202
+ check_associated_item ( tcx, trait_item. def_id , span, method_sig) ;
203
203
204
204
let encl_trait_hir_id = tcx. hir ( ) . get_parent_item ( hir_id) ;
205
205
let encl_trait = tcx. hir ( ) . expect_item ( encl_trait_hir_id) ;
@@ -327,7 +327,7 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
327
327
_ => ( None , impl_item. span ) ,
328
328
} ;
329
329
330
- check_associated_item ( tcx, impl_item. hir_id ( ) , span, method_sig) ;
330
+ check_associated_item ( tcx, impl_item. def_id , span, method_sig) ;
331
331
}
332
332
333
333
fn check_param_wf ( tcx : TyCtxt < ' _ > , param : & hir:: GenericParam < ' _ > ) {
@@ -437,13 +437,13 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
437
437
#[ tracing:: instrument( level = "debug" , skip( tcx, span, sig_if_method) ) ]
438
438
fn check_associated_item (
439
439
tcx : TyCtxt < ' _ > ,
440
- item_id : hir :: HirId ,
440
+ item_id : LocalDefId ,
441
441
span : Span ,
442
442
sig_if_method : Option < & hir:: FnSig < ' _ > > ,
443
443
) {
444
- let code = ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( item_id. expect_owner ( ) ) ) ) ;
444
+ let code = ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( item_id) ) ) ;
445
445
for_id ( tcx, item_id, span) . with_fcx ( |fcx| {
446
- let item = fcx. tcx . associated_item ( fcx . tcx . hir ( ) . local_def_id ( item_id) ) ;
446
+ let item = fcx. tcx . associated_item ( item_id) ;
447
447
448
448
let ( mut implied_bounds, self_ty) = match item. container {
449
449
ty:: TraitContainer ( _) => ( FxHashSet :: default ( ) , fcx. tcx . types . self_param ) ,
@@ -455,11 +455,7 @@ fn check_associated_item(
455
455
match item. kind {
456
456
ty:: AssocKind :: Const => {
457
457
let ty = fcx. tcx . type_of ( item. def_id ) ;
458
- let ty = fcx. normalize_associated_types_in_wf (
459
- span,
460
- ty,
461
- WellFormedLoc :: Ty ( item_id. expect_owner ( ) ) ,
462
- ) ;
458
+ let ty = fcx. normalize_associated_types_in_wf ( span, ty, WellFormedLoc :: Ty ( item_id) ) ;
463
459
fcx. register_wf_obligation ( ty. into ( ) , span, code. clone ( ) ) ;
464
460
}
465
461
ty:: AssocKind :: Fn => {
@@ -481,11 +477,8 @@ fn check_associated_item(
481
477
}
482
478
if item. defaultness . has_value ( ) {
483
479
let ty = fcx. tcx . type_of ( item. def_id ) ;
484
- let ty = fcx. normalize_associated_types_in_wf (
485
- span,
486
- ty,
487
- WellFormedLoc :: Ty ( item_id. expect_owner ( ) ) ,
488
- ) ;
480
+ let ty =
481
+ fcx. normalize_associated_types_in_wf ( span, ty, WellFormedLoc :: Ty ( item_id) ) ;
489
482
fcx. register_wf_obligation ( ty. into ( ) , span, code. clone ( ) ) ;
490
483
}
491
484
}
@@ -496,14 +489,13 @@ fn check_associated_item(
496
489
}
497
490
498
491
fn for_item < ' tcx > ( tcx : TyCtxt < ' tcx > , item : & hir:: Item < ' _ > ) -> CheckWfFcxBuilder < ' tcx > {
499
- for_id ( tcx, item. hir_id ( ) , item. span )
492
+ for_id ( tcx, item. def_id , item. span )
500
493
}
501
494
502
- fn for_id ( tcx : TyCtxt < ' _ > , id : hir:: HirId , span : Span ) -> CheckWfFcxBuilder < ' _ > {
503
- let def_id = tcx. hir ( ) . local_def_id ( id) ;
495
+ fn for_id ( tcx : TyCtxt < ' _ > , def_id : LocalDefId , span : Span ) -> CheckWfFcxBuilder < ' _ > {
504
496
CheckWfFcxBuilder {
505
497
inherited : Inherited :: build ( tcx, def_id) ,
506
- id,
498
+ id : hir :: HirId :: make_owner ( def_id ) ,
507
499
span,
508
500
param_env : tcx. param_env ( def_id) ,
509
501
}
@@ -665,30 +657,25 @@ fn check_associated_type_bounds(fcx: &FnCtxt<'_, '_>, item: &ty::AssocItem, span
665
657
666
658
fn check_item_fn (
667
659
tcx : TyCtxt < ' _ > ,
668
- item_id : hir :: HirId ,
660
+ def_id : LocalDefId ,
669
661
ident : Ident ,
670
662
span : Span ,
671
663
decl : & hir:: FnDecl < ' _ > ,
672
664
) {
673
- for_id ( tcx, item_id, span) . with_fcx ( |fcx| {
674
- let def_id = tcx. hir ( ) . local_def_id ( item_id) ;
665
+ for_id ( tcx, def_id, span) . with_fcx ( |fcx| {
675
666
let sig = tcx. fn_sig ( def_id) ;
676
667
let mut implied_bounds = FxHashSet :: default ( ) ;
677
668
check_fn_or_method ( fcx, ident. span , sig, decl, def_id. to_def_id ( ) , & mut implied_bounds) ;
678
669
implied_bounds
679
670
} )
680
671
}
681
672
682
- fn check_item_type ( tcx : TyCtxt < ' _ > , item_id : hir :: HirId , ty_span : Span , allow_foreign_ty : bool ) {
673
+ fn check_item_type ( tcx : TyCtxt < ' _ > , item_id : LocalDefId , ty_span : Span , allow_foreign_ty : bool ) {
683
674
debug ! ( "check_item_type: {:?}" , item_id) ;
684
675
685
676
for_id ( tcx, item_id, ty_span) . with_fcx ( |fcx| {
686
- let ty = tcx. type_of ( tcx. hir ( ) . local_def_id ( item_id) ) ;
687
- let item_ty = fcx. normalize_associated_types_in_wf (
688
- ty_span,
689
- ty,
690
- WellFormedLoc :: Ty ( item_id. expect_owner ( ) ) ,
691
- ) ;
677
+ let ty = tcx. type_of ( item_id) ;
678
+ let item_ty = fcx. normalize_associated_types_in_wf ( ty_span, ty, WellFormedLoc :: Ty ( item_id) ) ;
692
679
693
680
let mut forbid_unsized = true ;
694
681
if allow_foreign_ty {
@@ -701,7 +688,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
701
688
fcx. register_wf_obligation (
702
689
item_ty. into ( ) ,
703
690
ty_span,
704
- ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( item_id. expect_owner ( ) ) ) ) ,
691
+ ObligationCauseCode :: WellFormed ( Some ( WellFormedLoc :: Ty ( item_id) ) ) ,
705
692
) ;
706
693
if forbid_unsized {
707
694
fcx. register_bound (
0 commit comments