@@ -1292,46 +1292,36 @@ impl LintPass for UnsafeCode {
1292
1292
}
1293
1293
1294
1294
fn check_item ( & mut self , cx : & Context , it : & ast:: Item ) {
1295
- use syntax:: ast:: Unsafety :: Unsafe ;
1296
-
1297
- fn check_method ( cx : & Context , meth : & P < ast:: Method > ) {
1298
- if let ast:: Method_ :: MethDecl ( _, _, _, _, Unsafe , _, _, _) = meth. node {
1299
- cx. span_lint ( UNSAFE_CODE , meth. span , "implementation of an `unsafe` method" ) ;
1300
- }
1301
- }
1302
-
1303
1295
match it. node {
1304
- ast:: ItemFn ( _ , Unsafe , _, _, _) =>
1305
- cx. span_lint ( UNSAFE_CODE , it. span , "declaration of an `unsafe` function " ) ,
1296
+ ast:: ItemTrait ( ast :: Unsafety :: Unsafe , _, _, _) =>
1297
+ cx. span_lint ( UNSAFE_CODE , it. span , "declaration of an `unsafe` trait " ) ,
1306
1298
1307
- ast:: ItemTrait ( trait_safety, _, _, ref items) => {
1308
- if trait_safety == Unsafe {
1309
- cx. span_lint ( UNSAFE_CODE , it. span , "declaration of an `unsafe` trait" ) ;
1310
- }
1299
+ ast:: ItemImpl ( ast:: Unsafety :: Unsafe , _, _, _, _, _) =>
1300
+ cx. span_lint ( UNSAFE_CODE , it. span , "implementation of an `unsafe` trait" ) ,
1311
1301
1312
- for it in items {
1313
- match * it {
1314
- ast:: RequiredMethod ( ast:: TypeMethod { unsafety : Unsafe , span, ..} ) =>
1315
- cx. span_lint ( UNSAFE_CODE , span, "declaration of an `unsafe` method" ) ,
1316
- ast:: ProvidedMethod ( ref meth) => check_method ( cx, meth) ,
1317
- _ => ( ) ,
1318
- }
1319
- }
1320
- } ,
1302
+ _ => return ,
1303
+ }
1304
+ }
1321
1305
1322
- ast:: ItemImpl ( impl_safety, _, _, _, _, ref impls) => {
1323
- if impl_safety == Unsafe {
1324
- cx. span_lint ( UNSAFE_CODE , it. span , "implementation of an `unsafe` trait" ) ;
1325
- }
1306
+ fn check_fn ( & mut self , cx : & Context , fk : visit:: FnKind , _: & ast:: FnDecl ,
1307
+ _: & ast:: Block , span : Span , _: ast:: NodeId ) {
1308
+ match fk {
1309
+ visit:: FkItemFn ( _, _, ast:: Unsafety :: Unsafe , _) =>
1310
+ cx. span_lint ( UNSAFE_CODE , span, "declaration of an `unsafe` function" ) ,
1326
1311
1327
- for item in impls {
1328
- if let ast:: ImplItem :: MethodImplItem ( ref meth) = * item {
1329
- check_method ( cx, meth) ;
1330
- }
1312
+ visit:: FkMethod ( _, _, m) => {
1313
+ if let ast:: Method_ :: MethDecl ( _, _, _, _, ast:: Unsafety :: Unsafe , _, _, _) = m. node {
1314
+ cx. span_lint ( UNSAFE_CODE , m. span , "implementation of an `unsafe` method" )
1331
1315
}
1332
1316
} ,
1333
1317
1334
- _ => return ,
1318
+ _ => ( ) ,
1319
+ }
1320
+ }
1321
+
1322
+ fn check_ty_method ( & mut self , cx : & Context , ty_method : & ast:: TypeMethod ) {
1323
+ if let ast:: TypeMethod { unsafety : ast:: Unsafety :: Unsafe , span, ..} = * ty_method {
1324
+ cx. span_lint ( UNSAFE_CODE , span, "declaration of an `unsafe` method" )
1335
1325
}
1336
1326
}
1337
1327
}
0 commit comments