@@ -13,7 +13,6 @@ use crate::weak_lang_items;
13
13
use rustc_middle:: middle:: cstore:: ExternCrate ;
14
14
use rustc_middle:: ty:: TyCtxt ;
15
15
16
- use rustc_ast:: Attribute ;
17
16
use rustc_errors:: struct_span_err;
18
17
use rustc_hir as hir;
19
18
use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
@@ -30,29 +29,21 @@ struct LanguageItemCollector<'tcx> {
30
29
31
30
impl ItemLikeVisitor < ' v > for LanguageItemCollector < ' tcx > {
32
31
fn visit_item ( & mut self , item : & hir:: Item < ' _ > ) {
33
- self . check_for_lang ( Target :: from_item ( item) , item. hir_id ( ) , item . attrs ) ;
32
+ self . check_for_lang ( Target :: from_item ( item) , item. hir_id ( ) ) ;
34
33
35
34
if let hir:: ItemKind :: Enum ( def, ..) = & item. kind {
36
35
for variant in def. variants {
37
- self . check_for_lang ( Target :: Variant , variant. id , variant . attrs ) ;
36
+ self . check_for_lang ( Target :: Variant , variant. id ) ;
38
37
}
39
38
}
40
39
}
41
40
42
41
fn visit_trait_item ( & mut self , trait_item : & hir:: TraitItem < ' _ > ) {
43
- self . check_for_lang (
44
- Target :: from_trait_item ( trait_item) ,
45
- trait_item. hir_id ( ) ,
46
- trait_item. attrs ,
47
- )
42
+ self . check_for_lang ( Target :: from_trait_item ( trait_item) , trait_item. hir_id ( ) )
48
43
}
49
44
50
45
fn visit_impl_item ( & mut self , impl_item : & hir:: ImplItem < ' _ > ) {
51
- self . check_for_lang (
52
- target_from_impl_item ( self . tcx , impl_item) ,
53
- impl_item. hir_id ( ) ,
54
- impl_item. attrs ,
55
- )
46
+ self . check_for_lang ( target_from_impl_item ( self . tcx , impl_item) , impl_item. hir_id ( ) )
56
47
}
57
48
58
49
fn visit_foreign_item ( & mut self , _: & hir:: ForeignItem < ' _ > ) { }
@@ -63,7 +54,8 @@ impl LanguageItemCollector<'tcx> {
63
54
LanguageItemCollector { tcx, items : LanguageItems :: new ( ) }
64
55
}
65
56
66
- fn check_for_lang ( & mut self , actual_target : Target , hir_id : HirId , attrs : & [ Attribute ] ) {
57
+ fn check_for_lang ( & mut self , actual_target : Target , hir_id : HirId ) {
58
+ let attrs = self . tcx . hir ( ) . attrs ( hir_id) ;
67
59
let check_name = |attr, sym| self . tcx . sess . check_name ( attr, sym) ;
68
60
if let Some ( ( value, span) ) = extract ( check_name, & attrs) {
69
61
match ITEM_REFS . get ( & value) . cloned ( ) {
0 commit comments