@@ -5,7 +5,8 @@ use crate::utils::get_attr;
55use rustc:: hir;
66use rustc:: hir:: intravisit:: { NestedVisitorMap , Visitor } ;
77use rustc:: hir:: { BindingAnnotation , Expr , ExprKind , Pat , PatKind , QPath , Stmt , StmtKind , TyKind } ;
8- use rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
8+ use rustc:: lint:: { LateContext , LateLintPass , LintArray , LintContext , LintPass } ;
9+ use rustc:: session:: Session ;
910use rustc:: { declare_tool_lint, lint_array} ;
1011use rustc_data_structures:: fx:: FxHashMap ;
1112use syntax:: ast:: { Attribute , LitKind } ;
@@ -71,80 +72,80 @@ fn done() {
7172}
7273
7374impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for Pass {
74- fn check_item ( & mut self , _cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: Item ) {
75- if !has_attr ( & item. attrs ) {
75+ fn check_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: Item ) {
76+ if !has_attr ( cx . sess ( ) , & item. attrs ) {
7677 return ;
7778 }
7879 prelude ( ) ;
7980 PrintVisitor :: new ( "item" ) . visit_item ( item) ;
8081 done ( ) ;
8182 }
8283
83- fn check_impl_item ( & mut self , _cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: ImplItem ) {
84- if !has_attr ( & item. attrs ) {
84+ fn check_impl_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: ImplItem ) {
85+ if !has_attr ( cx . sess ( ) , & item. attrs ) {
8586 return ;
8687 }
8788 prelude ( ) ;
8889 PrintVisitor :: new ( "item" ) . visit_impl_item ( item) ;
8990 done ( ) ;
9091 }
9192
92- fn check_trait_item ( & mut self , _cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: TraitItem ) {
93- if !has_attr ( & item. attrs ) {
93+ fn check_trait_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: TraitItem ) {
94+ if !has_attr ( cx . sess ( ) , & item. attrs ) {
9495 return ;
9596 }
9697 prelude ( ) ;
9798 PrintVisitor :: new ( "item" ) . visit_trait_item ( item) ;
9899 done ( ) ;
99100 }
100101
101- fn check_variant ( & mut self , _cx : & LateContext < ' a , ' tcx > , var : & ' tcx hir:: Variant , generics : & hir:: Generics ) {
102- if !has_attr ( & var. node . attrs ) {
102+ fn check_variant ( & mut self , cx : & LateContext < ' a , ' tcx > , var : & ' tcx hir:: Variant , generics : & hir:: Generics ) {
103+ if !has_attr ( cx . sess ( ) , & var. node . attrs ) {
103104 return ;
104105 }
105106 prelude ( ) ;
106107 PrintVisitor :: new ( "var" ) . visit_variant ( var, generics, hir:: DUMMY_HIR_ID ) ;
107108 done ( ) ;
108109 }
109110
110- fn check_struct_field ( & mut self , _cx : & LateContext < ' a , ' tcx > , field : & ' tcx hir:: StructField ) {
111- if !has_attr ( & field. attrs ) {
111+ fn check_struct_field ( & mut self , cx : & LateContext < ' a , ' tcx > , field : & ' tcx hir:: StructField ) {
112+ if !has_attr ( cx . sess ( ) , & field. attrs ) {
112113 return ;
113114 }
114115 prelude ( ) ;
115116 PrintVisitor :: new ( "field" ) . visit_struct_field ( field) ;
116117 done ( ) ;
117118 }
118119
119- fn check_expr ( & mut self , _cx : & LateContext < ' a , ' tcx > , expr : & ' tcx hir:: Expr ) {
120- if !has_attr ( & expr. attrs ) {
120+ fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , expr : & ' tcx hir:: Expr ) {
121+ if !has_attr ( cx . sess ( ) , & expr. attrs ) {
121122 return ;
122123 }
123124 prelude ( ) ;
124125 PrintVisitor :: new ( "expr" ) . visit_expr ( expr) ;
125126 done ( ) ;
126127 }
127128
128- fn check_arm ( & mut self , _cx : & LateContext < ' a , ' tcx > , arm : & ' tcx hir:: Arm ) {
129- if !has_attr ( & arm. attrs ) {
129+ fn check_arm ( & mut self , cx : & LateContext < ' a , ' tcx > , arm : & ' tcx hir:: Arm ) {
130+ if !has_attr ( cx . sess ( ) , & arm. attrs ) {
130131 return ;
131132 }
132133 prelude ( ) ;
133134 PrintVisitor :: new ( "arm" ) . visit_arm ( arm) ;
134135 done ( ) ;
135136 }
136137
137- fn check_stmt ( & mut self , _cx : & LateContext < ' a , ' tcx > , stmt : & ' tcx hir:: Stmt ) {
138- if !has_attr ( stmt. node . attrs ( ) ) {
138+ fn check_stmt ( & mut self , cx : & LateContext < ' a , ' tcx > , stmt : & ' tcx hir:: Stmt ) {
139+ if !has_attr ( cx . sess ( ) , stmt. node . attrs ( ) ) {
139140 return ;
140141 }
141142 prelude ( ) ;
142143 PrintVisitor :: new ( "stmt" ) . visit_stmt ( stmt) ;
143144 done ( ) ;
144145 }
145146
146- fn check_foreign_item ( & mut self , _cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: ForeignItem ) {
147- if !has_attr ( & item. attrs ) {
147+ fn check_foreign_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx hir:: ForeignItem ) {
148+ if !has_attr ( cx . sess ( ) , & item. attrs ) {
148149 return ;
149150 }
150151 prelude ( ) ;
@@ -673,8 +674,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
673674 }
674675}
675676
676- fn has_attr ( attrs : & [ Attribute ] ) -> bool {
677- get_attr ( attrs, "author" ) . count ( ) > 0
677+ fn has_attr ( sess : & Session , attrs : & [ Attribute ] ) -> bool {
678+ get_attr ( sess , attrs, "author" ) . count ( ) > 0
678679}
679680
680681fn desugaring_name ( des : hir:: MatchSource ) -> String {
0 commit comments