@@ -5,7 +5,8 @@ use crate::utils::get_attr;
5
5
use rustc:: hir;
6
6
use rustc:: hir:: intravisit:: { NestedVisitorMap , Visitor } ;
7
7
use 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 ;
9
10
use rustc:: { declare_tool_lint, lint_array} ;
10
11
use rustc_data_structures:: fx:: FxHashMap ;
11
12
use syntax:: ast:: { Attribute , LitKind } ;
@@ -71,80 +72,80 @@ fn done() {
71
72
}
72
73
73
74
impl < ' 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 ) {
76
77
return ;
77
78
}
78
79
prelude ( ) ;
79
80
PrintVisitor :: new ( "item" ) . visit_item ( item) ;
80
81
done ( ) ;
81
82
}
82
83
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 ) {
85
86
return ;
86
87
}
87
88
prelude ( ) ;
88
89
PrintVisitor :: new ( "item" ) . visit_impl_item ( item) ;
89
90
done ( ) ;
90
91
}
91
92
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 ) {
94
95
return ;
95
96
}
96
97
prelude ( ) ;
97
98
PrintVisitor :: new ( "item" ) . visit_trait_item ( item) ;
98
99
done ( ) ;
99
100
}
100
101
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 ) {
103
104
return ;
104
105
}
105
106
prelude ( ) ;
106
107
PrintVisitor :: new ( "var" ) . visit_variant ( var, generics, hir:: DUMMY_HIR_ID ) ;
107
108
done ( ) ;
108
109
}
109
110
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 ) {
112
113
return ;
113
114
}
114
115
prelude ( ) ;
115
116
PrintVisitor :: new ( "field" ) . visit_struct_field ( field) ;
116
117
done ( ) ;
117
118
}
118
119
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 ) {
121
122
return ;
122
123
}
123
124
prelude ( ) ;
124
125
PrintVisitor :: new ( "expr" ) . visit_expr ( expr) ;
125
126
done ( ) ;
126
127
}
127
128
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 ) {
130
131
return ;
131
132
}
132
133
prelude ( ) ;
133
134
PrintVisitor :: new ( "arm" ) . visit_arm ( arm) ;
134
135
done ( ) ;
135
136
}
136
137
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 ( ) ) {
139
140
return ;
140
141
}
141
142
prelude ( ) ;
142
143
PrintVisitor :: new ( "stmt" ) . visit_stmt ( stmt) ;
143
144
done ( ) ;
144
145
}
145
146
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 ) {
148
149
return ;
149
150
}
150
151
prelude ( ) ;
@@ -673,8 +674,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
673
674
}
674
675
}
675
676
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
678
679
}
679
680
680
681
fn desugaring_name ( des : hir:: MatchSource ) -> String {
0 commit comments