@@ -433,17 +433,13 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
433
433
match ecx. tcx . trait_items_cache . borrow ( ) . get ( & exp. def_id ) {
434
434
Some ( trait_items) => {
435
435
for trait_item in trait_items. iter ( ) {
436
- match * trait_item {
437
- ty:: MethodTraitItem ( ref m) => {
438
- encode_reexported_static_method ( rbml_w,
439
- exp,
440
- m. def_id ,
441
- m. name ) ;
442
- }
443
- _ => { }
436
+ if let ty:: MethodTraitItem ( ref m) = * trait_item {
437
+ encode_reexported_static_method ( rbml_w,
438
+ exp,
439
+ m. def_id ,
440
+ m. name ) ;
444
441
}
445
442
}
446
-
447
443
true
448
444
}
449
445
None => { false }
@@ -454,46 +450,42 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
454
450
rbml_w : & mut Encoder ,
455
451
mod_path : PathElems ,
456
452
exp : & middle:: resolve:: Export2 ) {
457
- match ecx. tcx . map . find ( exp. def_id . node ) {
458
- Some ( ast_map:: NodeItem ( item) ) => {
459
- let original_name = token:: get_ident ( item. ident ) ;
460
-
461
- let path_differs = ecx. tcx . map . with_path ( exp. def_id . node , |path| {
462
- let ( mut a, mut b) = ( path, mod_path. clone ( ) ) ;
463
- loop {
464
- match ( a. next ( ) , b. next ( ) ) {
465
- ( None , None ) => return true ,
466
- ( None , _) | ( _, None ) => return false ,
467
- ( Some ( x) , Some ( y) ) => if x != y { return false } ,
468
- }
453
+ if let Some ( ast_map:: NodeItem ( item) ) = ecx. tcx . map . find ( exp. def_id . node ) {
454
+ let original_name = token:: get_ident ( item. ident ) ;
455
+
456
+ let path_differs = ecx. tcx . map . with_path ( exp. def_id . node , |path| {
457
+ let ( mut a, mut b) = ( path, mod_path. clone ( ) ) ;
458
+ loop {
459
+ match ( a. next ( ) , b. next ( ) ) {
460
+ ( None , None ) => return true ,
461
+ ( None , _) | ( _, None ) => return false ,
462
+ ( Some ( x) , Some ( y) ) => if x != y { return false } ,
469
463
}
470
- } ) ;
464
+ }
465
+ } ) ;
471
466
472
- //
473
- // We don't need to reexport static methods on items
474
- // declared in the same module as our `pub use ...` since
475
- // that's done when we encode the item itself.
476
- //
477
- // The only exception is when the reexport *changes* the
478
- // name e.g. `pub use Foo = self::Bar` -- we have
479
- // encoded metadata for static methods relative to Bar,
480
- // but not yet for Foo.
481
- //
482
- if path_differs || original_name. get ( ) != exp. name . as_slice ( ) {
483
- if !encode_reexported_static_base_methods ( ecx, rbml_w, exp) {
484
- if encode_reexported_static_trait_methods ( ecx, rbml_w, exp) {
485
- debug ! ( "(encode reexported static methods) {} \
486
- [trait]",
487
- original_name) ;
488
- }
489
- }
490
- else {
491
- debug ! ( "(encode reexported static methods) {} [base]" ,
492
- original_name) ;
467
+ //
468
+ // We don't need to reexport static methods on items
469
+ // declared in the same module as our `pub use ...` since
470
+ // that's done when we encode the item itself.
471
+ //
472
+ // The only exception is when the reexport *changes* the
473
+ // name e.g. `pub use Foo = self::Bar` -- we have
474
+ // encoded metadata for static methods relative to Bar,
475
+ // but not yet for Foo.
476
+ //
477
+ if path_differs || original_name. get ( ) != exp. name . as_slice ( ) {
478
+ if !encode_reexported_static_base_methods ( ecx, rbml_w, exp) {
479
+ if encode_reexported_static_trait_methods ( ecx, rbml_w, exp) {
480
+ debug ! ( "(encode reexported static methods) {} [trait]" ,
481
+ original_name) ;
493
482
}
494
483
}
484
+ else {
485
+ debug ! ( "(encode reexported static methods) {} [base]" ,
486
+ original_name) ;
487
+ }
495
488
}
496
- _ => { }
497
489
}
498
490
}
499
491
@@ -581,19 +573,15 @@ fn encode_info_for_mod(ecx: &EncodeContext,
581
573
true
582
574
} ) ;
583
575
584
- match item. node {
585
- ast:: ItemImpl ( ..) => {
586
- let ( ident, did) = ( item. ident , item. id ) ;
587
- debug ! ( "(encoding info for module) ... encoding impl {} \
588
- ({}/{})",
589
- token:: get_ident( ident) ,
590
- did, ecx. tcx. map. node_to_string( did) ) ;
576
+ if let ast:: ItemImpl ( ..) = item. node {
577
+ let ( ident, did) = ( item. ident , item. id ) ;
578
+ debug ! ( "(encoding info for module) ... encoding impl {} ({}/{})" ,
579
+ token:: get_ident( ident) ,
580
+ did, ecx. tcx. map. node_to_string( did) ) ;
591
581
592
- rbml_w. start_tag ( tag_mod_impl) ;
593
- rbml_w. wr_str ( def_to_string ( local_def ( did) ) . as_slice ( ) ) ;
594
- rbml_w. end_tag ( ) ;
595
- }
596
- _ => { }
582
+ rbml_w. start_tag ( tag_mod_impl) ;
583
+ rbml_w. wr_str ( def_to_string ( local_def ( did) ) . as_slice ( ) ) ;
584
+ rbml_w. end_tag ( ) ;
597
585
}
598
586
}
599
587
@@ -923,12 +911,9 @@ fn encode_method_argument_names(rbml_w: &mut Encoder,
923
911
rbml_w. start_tag ( tag_method_argument_names) ;
924
912
for arg in decl. inputs . iter ( ) {
925
913
rbml_w. start_tag ( tag_method_argument_name) ;
926
- match arg. pat . node {
927
- ast:: PatIdent ( _, ref path1, _) => {
928
- let name = token:: get_ident ( path1. node ) ;
929
- rbml_w. writer . write ( name. get ( ) . as_bytes ( ) ) ;
930
- }
931
- _ => { }
914
+ if let ast:: PatIdent ( _, ref path1, _) = arg. pat . node {
915
+ let name = token:: get_ident ( path1. node ) ;
916
+ rbml_w. writer . write ( name. get ( ) . as_bytes ( ) ) ;
932
917
}
933
918
rbml_w. end_tag ( ) ;
934
919
}
@@ -1854,22 +1839,19 @@ struct ImplVisitor<'a, 'b:'a, 'c:'a, 'tcx:'b> {
1854
1839
1855
1840
impl < ' a , ' b , ' c , ' tcx , ' v > Visitor < ' v > for ImplVisitor < ' a , ' b , ' c , ' tcx > {
1856
1841
fn visit_item ( & mut self , item : & ast:: Item ) {
1857
- match item. node {
1858
- ast:: ItemImpl ( _, Some ( ref trait_ref) , _, _) => {
1859
- let def_map = & self . ecx . tcx . def_map ;
1860
- let trait_def = def_map. borrow ( ) [ trait_ref. ref_id ] . clone ( ) ;
1861
- let def_id = trait_def. def_id ( ) ;
1862
-
1863
- // Load eagerly if this is an implementation of the Drop trait
1864
- // or if the trait is not defined in this crate.
1865
- if Some ( def_id) == self . ecx . tcx . lang_items . drop_trait ( ) ||
1866
- def_id. krate != ast:: LOCAL_CRATE {
1867
- self . rbml_w . start_tag ( tag_impls_impl) ;
1868
- encode_def_id ( self . rbml_w , local_def ( item. id ) ) ;
1869
- self . rbml_w . end_tag ( ) ;
1870
- }
1842
+ if let ast:: ItemImpl ( _, Some ( ref trait_ref) , _, _) = item. node {
1843
+ let def_map = & self . ecx . tcx . def_map ;
1844
+ let trait_def = def_map. borrow ( ) [ trait_ref. ref_id ] . clone ( ) ;
1845
+ let def_id = trait_def. def_id ( ) ;
1846
+
1847
+ // Load eagerly if this is an implementation of the Drop trait
1848
+ // or if the trait is not defined in this crate.
1849
+ if Some ( def_id) == self . ecx . tcx . lang_items . drop_trait ( ) ||
1850
+ def_id. krate != ast:: LOCAL_CRATE {
1851
+ self . rbml_w . start_tag ( tag_impls_impl) ;
1852
+ encode_def_id ( self . rbml_w , local_def ( item. id ) ) ;
1853
+ self . rbml_w . end_tag ( ) ;
1871
1854
}
1872
- _ => { }
1873
1855
}
1874
1856
visit:: walk_item ( self , item) ;
1875
1857
}
@@ -1931,17 +1913,12 @@ fn encode_reachable_extern_fns(ecx: &EncodeContext, rbml_w: &mut Encoder) {
1931
1913
rbml_w. start_tag ( tag_reachable_extern_fns) ;
1932
1914
1933
1915
for id in ecx. reachable . iter ( ) {
1934
- match ecx. tcx . map . find ( * id) {
1935
- Some ( ast_map:: NodeItem ( i) ) => {
1936
- match i. node {
1937
- ast:: ItemFn ( _, _, abi, ref generics, _)
1938
- if abi != abi:: Rust && !generics. is_type_parameterized ( ) => {
1939
- rbml_w. wr_tagged_u32 ( tag_reachable_extern_fn_id, * id) ;
1940
- }
1941
- _ => { }
1916
+ if let Some ( ast_map:: NodeItem ( i) ) = ecx. tcx . map . find ( * id) {
1917
+ if let ast:: ItemFn ( _, _, abi, ref generics, _) = i. node {
1918
+ if abi != abi:: Rust && !generics. is_type_parameterized ( ) {
1919
+ rbml_w. wr_tagged_u32 ( tag_reachable_extern_fn_id, * id) ;
1942
1920
}
1943
1921
}
1944
- _ => { }
1945
1922
}
1946
1923
}
1947
1924
0 commit comments