@@ -835,12 +835,11 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
835
835
encode_method_fty ( ecx, rbml_w, & method_ty. fty ) ;
836
836
encode_visibility ( rbml_w, method_ty. vis ) ;
837
837
encode_explicit_self ( rbml_w, & method_ty. explicit_self ) ;
838
- let fn_style = method_ty. fty . fn_style ;
839
838
match method_ty. explicit_self {
840
839
ty:: StaticExplicitSelfCategory => {
841
- encode_family ( rbml_w, fn_style_static_method_family ( fn_style ) ) ;
840
+ encode_family ( rbml_w, STATIC_METHOD_FAMILY ) ;
842
841
}
843
- _ => encode_family ( rbml_w, style_fn_family ( fn_style ) )
842
+ _ => encode_family ( rbml_w, METHOD_FAMILY )
844
843
}
845
844
encode_provided_source ( rbml_w, method_ty. provided_source ) ;
846
845
}
@@ -964,20 +963,9 @@ fn encode_inlined_item(ecx: &EncodeContext,
964
963
( * eii) ( ecx, rbml_w, ii)
965
964
}
966
965
967
- fn style_fn_family ( s : FnStyle ) -> char {
968
- match s {
969
- UnsafeFn => 'u' ,
970
- NormalFn => 'f' ,
971
- }
972
- }
973
-
974
- fn fn_style_static_method_family ( s : FnStyle ) -> char {
975
- match s {
976
- UnsafeFn => 'U' ,
977
- NormalFn => 'F' ,
978
- }
979
- }
980
-
966
+ const FN_FAMILY : char = 'f' ;
967
+ const STATIC_METHOD_FAMILY : char = 'F' ;
968
+ const METHOD_FAMILY : char = 'h' ;
981
969
982
970
fn should_inline ( attrs : & [ Attribute ] ) -> bool {
983
971
use syntax:: attr:: * ;
@@ -1081,11 +1069,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
1081
1069
encode_stability ( rbml_w, stab) ;
1082
1070
rbml_w. end_tag ( ) ;
1083
1071
}
1084
- ItemFn ( ref decl, fn_style , _, ref generics, _) => {
1072
+ ItemFn ( ref decl, _ , _, ref generics, _) => {
1085
1073
add_to_index ( item, rbml_w, index) ;
1086
1074
rbml_w. start_tag ( tag_items_data_item) ;
1087
1075
encode_def_id ( rbml_w, def_id) ;
1088
- encode_family ( rbml_w, style_fn_family ( fn_style ) ) ;
1076
+ encode_family ( rbml_w, FN_FAMILY ) ;
1089
1077
let tps_len = generics. ty_params . len ( ) ;
1090
1078
encode_bounds_and_type ( rbml_w, ecx, & lookup_item_type ( tcx, def_id) ) ;
1091
1079
encode_name ( rbml_w, item. ident . name ) ;
@@ -1402,13 +1390,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
1402
1390
match method_ty. explicit_self {
1403
1391
ty:: StaticExplicitSelfCategory => {
1404
1392
encode_family ( rbml_w,
1405
- fn_style_static_method_family (
1406
- method_ty. fty . fn_style ) ) ;
1393
+ STATIC_METHOD_FAMILY ) ;
1407
1394
}
1408
1395
_ => {
1409
1396
encode_family ( rbml_w,
1410
- style_fn_family (
1411
- method_ty. fty . fn_style ) ) ;
1397
+ METHOD_FAMILY ) ;
1412
1398
}
1413
1399
}
1414
1400
let pty = ty:: lookup_item_type ( tcx,
@@ -1432,30 +1418,30 @@ fn encode_info_for_item(ecx: &EncodeContext,
1432
1418
encode_parent_sort ( rbml_w, 't' ) ;
1433
1419
1434
1420
let trait_item = & ms[ i] ;
1435
- match & ms[ i] {
1436
- & RequiredMethod ( ref tm) => {
1437
- encode_attributes ( rbml_w, tm. attrs . as_slice ( ) ) ;
1421
+ let encode_trait_item = |rbml_w : & mut Encoder | {
1422
+ // If this is a static method, we've already
1423
+ // encoded this.
1424
+ if is_nonstatic_method {
1425
+ // FIXME: I feel like there is something funny
1426
+ // going on.
1427
+ let pty = ty:: lookup_item_type ( tcx, item_def_id. def_id ( ) ) ;
1428
+ encode_bounds_and_type ( rbml_w, ecx, & pty) ;
1429
+ }
1430
+ } ;
1431
+ match trait_item {
1432
+ & RequiredMethod ( ref m) => {
1433
+ encode_attributes ( rbml_w, m. attrs . as_slice ( ) ) ;
1434
+ encode_trait_item ( rbml_w) ;
1438
1435
encode_item_sort ( rbml_w, 'r' ) ;
1439
- encode_method_argument_names ( rbml_w, & * tm . decl ) ;
1436
+ encode_method_argument_names ( rbml_w, & * m . decl ) ;
1440
1437
}
1441
1438
1442
1439
& ProvidedMethod ( ref m) => {
1443
1440
encode_attributes ( rbml_w, m. attrs . as_slice ( ) ) ;
1444
- // If this is a static method, we've already
1445
- // encoded this.
1446
- if is_nonstatic_method {
1447
- // FIXME: I feel like there is something funny
1448
- // going on.
1449
- let pty = ty:: lookup_item_type ( tcx,
1450
- item_def_id. def_id ( ) ) ;
1451
- encode_bounds_and_type ( rbml_w, ecx, & pty) ;
1452
- }
1441
+ encode_trait_item ( rbml_w) ;
1453
1442
encode_item_sort ( rbml_w, 'p' ) ;
1454
- encode_inlined_item ( ecx,
1455
- rbml_w,
1456
- IITraitItemRef ( def_id, trait_item) ) ;
1457
- encode_method_argument_names ( rbml_w,
1458
- & * m. pe_fn_decl ( ) ) ;
1443
+ encode_inlined_item ( ecx, rbml_w, IITraitItemRef ( def_id, trait_item) ) ;
1444
+ encode_method_argument_names ( rbml_w, & * m. pe_fn_decl ( ) ) ;
1459
1445
}
1460
1446
1461
1447
& TypeTraitItem ( ref associated_type) => {
@@ -1493,7 +1479,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
1493
1479
encode_visibility ( rbml_w, nitem. vis ) ;
1494
1480
match nitem. node {
1495
1481
ForeignItemFn ( ..) => {
1496
- encode_family ( rbml_w, style_fn_family ( NormalFn ) ) ;
1482
+ encode_family ( rbml_w, FN_FAMILY ) ;
1497
1483
encode_bounds_and_type ( rbml_w, ecx,
1498
1484
& lookup_item_type ( ecx. tcx , local_def ( nitem. id ) ) ) ;
1499
1485
encode_name ( rbml_w, nitem. ident . name ) ;
0 commit comments