@@ -46,7 +46,7 @@ use syntax::attr::{self, AttrMetaMethods};
46
46
use syntax:: codemap:: { self , Span } ;
47
47
48
48
use rustc_front:: hir;
49
- use rustc_front:: visit:: { self , FnKind , Visitor } ;
49
+ use rustc_front:: visit:: FnKind ;
50
50
51
51
use bad_style:: { MethodLateContext , method_context} ;
52
52
@@ -138,92 +138,6 @@ impl LateLintPass for BoxPointers {
138
138
}
139
139
}
140
140
141
- declare_lint ! {
142
- RAW_POINTER_DERIVE ,
143
- Warn ,
144
- "uses of #[derive] with raw pointers are rarely correct"
145
- }
146
-
147
- struct RawPtrDeriveVisitor < ' a , ' tcx : ' a > {
148
- cx : & ' a LateContext < ' a , ' tcx >
149
- }
150
-
151
- impl < ' a , ' tcx , ' v > Visitor < ' v > for RawPtrDeriveVisitor < ' a , ' tcx > {
152
- fn visit_ty ( & mut self , ty : & hir:: Ty ) {
153
- const MSG : & ' static str = "use of `#[derive]` with a raw pointer" ;
154
- if let hir:: TyPtr ( ..) = ty. node {
155
- self . cx . span_lint ( RAW_POINTER_DERIVE , ty. span , MSG ) ;
156
- }
157
- visit:: walk_ty ( self , ty) ;
158
- }
159
- // explicit override to a no-op to reduce code bloat
160
- fn visit_expr ( & mut self , _: & hir:: Expr ) { }
161
- fn visit_block ( & mut self , _: & hir:: Block ) { }
162
- }
163
-
164
- pub struct RawPointerDerive {
165
- checked_raw_pointers : NodeSet ,
166
- }
167
-
168
- impl RawPointerDerive {
169
- pub fn new ( ) -> RawPointerDerive {
170
- RawPointerDerive {
171
- checked_raw_pointers : NodeSet ( ) ,
172
- }
173
- }
174
- }
175
-
176
- impl LintPass for RawPointerDerive {
177
- fn get_lints ( & self ) -> LintArray {
178
- lint_array ! ( RAW_POINTER_DERIVE )
179
- }
180
- }
181
-
182
- impl LateLintPass for RawPointerDerive {
183
- fn check_item ( & mut self , cx : & LateContext , item : & hir:: Item ) {
184
- if !attr:: contains_name ( & item. attrs , "automatically_derived" ) {
185
- return ;
186
- }
187
- let did = match item. node {
188
- hir:: ItemImpl ( _, _, _, ref t_ref_opt, _, _) => {
189
- // Deriving the Copy trait does not cause a warning
190
- if let & Some ( ref trait_ref) = t_ref_opt {
191
- let def_id = cx. tcx . trait_ref_to_def_id ( trait_ref) ;
192
- if Some ( def_id) == cx. tcx . lang_items . copy_trait ( ) {
193
- return ;
194
- }
195
- }
196
-
197
- match cx. tcx . node_id_to_type ( item. id ) . sty {
198
- ty:: TyEnum ( def, _) => def. did ,
199
- ty:: TyStruct ( def, _) => def. did ,
200
- _ => return ,
201
- }
202
- }
203
- _ => return ,
204
- } ;
205
- let node_id = if let Some ( node_id) = cx. tcx . map . as_local_node_id ( did) {
206
- node_id
207
- } else {
208
- return ;
209
- } ;
210
- let item = match cx. tcx . map . find ( node_id) {
211
- Some ( hir_map:: NodeItem ( item) ) => item,
212
- _ => return ,
213
- } ;
214
- if !self . checked_raw_pointers . insert ( item. id ) {
215
- return ;
216
- }
217
- match item. node {
218
- hir:: ItemStruct ( ..) | hir:: ItemEnum ( ..) => {
219
- let mut visitor = RawPtrDeriveVisitor { cx : cx } ;
220
- visit:: walk_item ( & mut visitor, & item) ;
221
- }
222
- _ => { }
223
- }
224
- }
225
- }
226
-
227
141
declare_lint ! {
228
142
NON_SHORTHAND_FIELD_PATTERNS ,
229
143
Warn ,
0 commit comments