@@ -466,8 +466,9 @@ impl<'a> State<'a> {
466
466
}
467
467
468
468
pub fn print_foreign_item ( & mut self , item : & hir:: ForeignItem < ' _ > ) {
469
+ let item_span = self . span ( item. hir_id ) ;
469
470
self . hardbreak_if_not_bol ( ) ;
470
- self . maybe_print_comment ( item . span . lo ( ) ) ;
471
+ self . maybe_print_comment ( item_span . lo ( ) ) ;
471
472
self . print_outer_attributes ( & item. attrs ) ;
472
473
match item. kind {
473
474
hir:: ForeignItemKind :: Fn ( ref decl, ref arg_names, ref generics) => {
@@ -574,8 +575,9 @@ impl<'a> State<'a> {
574
575
575
576
/// Pretty-print an item
576
577
pub fn print_item ( & mut self , item : & hir:: Item < ' _ > ) {
578
+ let span = self . span ( item. hir_id ) ;
577
579
self . hardbreak_if_not_bol ( ) ;
578
- self . maybe_print_comment ( item . span . lo ( ) ) ;
580
+ self . maybe_print_comment ( span. lo ( ) ) ;
579
581
self . print_outer_attributes ( & item. attrs ) ;
580
582
self . ann . pre ( self , AnnNode :: Item ( item) ) ;
581
583
match item. kind {
@@ -662,14 +664,14 @@ impl<'a> State<'a> {
662
664
self . nbsp ( ) ;
663
665
self . bopen ( ) ;
664
666
self . print_mod ( _mod, & item. attrs ) ;
665
- self . bclose ( item . span ) ;
667
+ self . bclose ( span) ;
666
668
}
667
669
hir:: ItemKind :: ForeignMod ( ref nmod) => {
668
670
self . head ( "extern" ) ;
669
671
self . word_nbsp ( nmod. abi . to_string ( ) ) ;
670
672
self . bopen ( ) ;
671
673
self . print_foreign_mod ( nmod, & item. attrs ) ;
672
- self . bclose ( item . span ) ;
674
+ self . bclose ( span) ;
673
675
}
674
676
hir:: ItemKind :: GlobalAsm ( ref ga) => {
675
677
self . head ( visibility_qualified ( & item. vis , "global asm" ) ) ;
@@ -698,15 +700,15 @@ impl<'a> State<'a> {
698
700
} ) ;
699
701
}
700
702
hir:: ItemKind :: Enum ( ref enum_definition, ref params) => {
701
- self . print_enum_def ( enum_definition, params, item. ident . name , item . span , & item. vis ) ;
703
+ self . print_enum_def ( enum_definition, params, item. ident . name , span, & item. vis ) ;
702
704
}
703
705
hir:: ItemKind :: Struct ( ref struct_def, ref generics) => {
704
706
self . head ( visibility_qualified ( & item. vis , "struct" ) ) ;
705
- self . print_struct ( struct_def, generics, item. ident . name , item . span , true ) ;
707
+ self . print_struct ( struct_def, generics, item. ident . name , span, true ) ;
706
708
}
707
709
hir:: ItemKind :: Union ( ref struct_def, ref generics) => {
708
710
self . head ( visibility_qualified ( & item. vis , "union" ) ) ;
709
- self . print_struct ( struct_def, generics, item. ident . name , item . span , true ) ;
711
+ self . print_struct ( struct_def, generics, item. ident . name , span, true ) ;
710
712
}
711
713
hir:: ItemKind :: Impl {
712
714
unsafety,
@@ -753,7 +755,7 @@ impl<'a> State<'a> {
753
755
for impl_item in items {
754
756
self . ann . nested ( self , Nested :: ImplItem ( impl_item. id ) ) ;
755
757
}
756
- self . bclose ( item . span ) ;
758
+ self . bclose ( span) ;
757
759
}
758
760
hir:: ItemKind :: Trait ( is_auto, unsafety, ref generics, ref bounds, trait_items) => {
759
761
self . head ( "" ) ;
@@ -780,7 +782,7 @@ impl<'a> State<'a> {
780
782
for trait_item in trait_items {
781
783
self . ann . nested ( self , Nested :: TraitItem ( trait_item. id ) ) ;
782
784
}
783
- self . bclose ( item . span ) ;
785
+ self . bclose ( span) ;
784
786
}
785
787
hir:: ItemKind :: TraitAlias ( ref generics, ref bounds) => {
786
788
self . head ( "" ) ;
@@ -961,9 +963,10 @@ impl<'a> State<'a> {
961
963
}
962
964
963
965
pub fn print_trait_item ( & mut self , ti : & hir:: TraitItem < ' _ > ) {
966
+ let span = self . span ( ti. hir_id ) ;
964
967
self . ann . pre ( self , AnnNode :: SubItem ( ti. hir_id ) ) ;
965
968
self . hardbreak_if_not_bol ( ) ;
966
- self . maybe_print_comment ( ti . span . lo ( ) ) ;
969
+ self . maybe_print_comment ( span. lo ( ) ) ;
967
970
self . print_outer_attributes ( & ti. attrs ) ;
968
971
match ti. kind {
969
972
hir:: TraitItemKind :: Const ( ref ty, default) => {
@@ -1000,9 +1003,10 @@ impl<'a> State<'a> {
1000
1003
}
1001
1004
1002
1005
pub fn print_impl_item ( & mut self , ii : & hir:: ImplItem < ' _ > ) {
1006
+ let span = self . span ( ii. hir_id ) ;
1003
1007
self . ann . pre ( self , AnnNode :: SubItem ( ii. hir_id ) ) ;
1004
1008
self . hardbreak_if_not_bol ( ) ;
1005
- self . maybe_print_comment ( ii . span . lo ( ) ) ;
1009
+ self . maybe_print_comment ( span. lo ( ) ) ;
1006
1010
self . print_outer_attributes ( & ii. attrs ) ;
1007
1011
self . print_defaultness ( ii. defaultness ) ;
1008
1012
0 commit comments