@@ -16,7 +16,7 @@ use crate::weak_lang_items;
1616use rustc_hir as hir;
1717use rustc_hir:: def:: DefKind ;
1818use rustc_hir:: def_id:: DefId ;
19- use rustc_hir:: lang_items:: { extract, GenericRequirement , ITEM_REFS } ;
19+ use rustc_hir:: lang_items:: { extract, GenericRequirement } ;
2020use rustc_hir:: { HirId , LangItem , LanguageItems , Target } ;
2121use rustc_middle:: ty:: TyCtxt ;
2222use rustc_session:: cstore:: ExternCrate ;
@@ -43,17 +43,17 @@ impl<'tcx> LanguageItemCollector<'tcx> {
4343 fn check_for_lang ( & mut self , actual_target : Target , hir_id : HirId ) {
4444 let attrs = self . tcx . hir ( ) . attrs ( hir_id) ;
4545 if let Some ( ( name, span) ) = extract ( & attrs) {
46- match ITEM_REFS . get ( & name) . cloned ( ) {
46+ match LangItem :: from_name ( name) {
4747 // Known lang item with attribute on correct target.
48- Some ( ( item_index , expected_target ) ) if actual_target == expected_target => {
49- self . collect_item_extended ( item_index , hir_id, span) ;
48+ Some ( lang_item ) if actual_target == lang_item . target ( ) => {
49+ self . collect_item_extended ( lang_item , hir_id, span) ;
5050 }
5151 // Known lang item with attribute on incorrect target.
52- Some ( ( _ , expected_target ) ) => {
52+ Some ( lang_item ) => {
5353 self . tcx . sess . emit_err ( LangItemOnIncorrectTarget {
5454 span,
5555 name,
56- expected_target,
56+ expected_target : lang_item . target ( ) ,
5757 actual_target,
5858 } ) ;
5959 }
@@ -147,9 +147,8 @@ impl<'tcx> LanguageItemCollector<'tcx> {
147147
148148 // Like collect_item() above, but also checks whether the lang item is declared
149149 // with the right number of generic arguments.
150- fn collect_item_extended ( & mut self , item_index : usize , hir_id : HirId , span : Span ) {
150+ fn collect_item_extended ( & mut self , lang_item : LangItem , hir_id : HirId , span : Span ) {
151151 let item_def_id = self . tcx . hir ( ) . local_def_id ( hir_id) . to_def_id ( ) ;
152- let lang_item = LangItem :: from_u32 ( item_index as u32 ) . unwrap ( ) ;
153152 let name = lang_item. name ( ) ;
154153
155154 // Now check whether the lang_item has the expected number of generic
0 commit comments