@@ -466,8 +466,9 @@ impl<'a> State<'a> {
466466 }
467467
468468 pub fn print_foreign_item ( & mut self , item : & hir:: ForeignItem < ' _ > ) {
469+ let item_span = self . span ( item. hir_id ) ;
469470 self . hardbreak_if_not_bol ( ) ;
470- self . maybe_print_comment ( item . span . lo ( ) ) ;
471+ self . maybe_print_comment ( item_span . lo ( ) ) ;
471472 self . print_outer_attributes ( & item. attrs ) ;
472473 match item. kind {
473474 hir:: ForeignItemKind :: Fn ( ref decl, ref arg_names, ref generics) => {
@@ -574,8 +575,9 @@ impl<'a> State<'a> {
574575
575576 /// Pretty-print an item
576577 pub fn print_item ( & mut self , item : & hir:: Item < ' _ > ) {
578+ let span = self . span ( item. hir_id ) ;
577579 self . hardbreak_if_not_bol ( ) ;
578- self . maybe_print_comment ( item . span . lo ( ) ) ;
580+ self . maybe_print_comment ( span. lo ( ) ) ;
579581 self . print_outer_attributes ( & item. attrs ) ;
580582 self . ann . pre ( self , AnnNode :: Item ( item) ) ;
581583 match item. kind {
@@ -662,14 +664,14 @@ impl<'a> State<'a> {
662664 self . nbsp ( ) ;
663665 self . bopen ( ) ;
664666 self . print_mod ( _mod, & item. attrs ) ;
665- self . bclose ( item . span ) ;
667+ self . bclose ( span) ;
666668 }
667669 hir:: ItemKind :: ForeignMod ( ref nmod) => {
668670 self . head ( "extern" ) ;
669671 self . word_nbsp ( nmod. abi . to_string ( ) ) ;
670672 self . bopen ( ) ;
671673 self . print_foreign_mod ( nmod, & item. attrs ) ;
672- self . bclose ( item . span ) ;
674+ self . bclose ( span) ;
673675 }
674676 hir:: ItemKind :: GlobalAsm ( ref ga) => {
675677 self . head ( visibility_qualified ( & item. vis , "global asm" ) ) ;
@@ -698,15 +700,15 @@ impl<'a> State<'a> {
698700 } ) ;
699701 }
700702 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 ) ;
702704 }
703705 hir:: ItemKind :: Struct ( ref struct_def, ref generics) => {
704706 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 ) ;
706708 }
707709 hir:: ItemKind :: Union ( ref struct_def, ref generics) => {
708710 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 ) ;
710712 }
711713 hir:: ItemKind :: Impl {
712714 unsafety,
@@ -753,7 +755,7 @@ impl<'a> State<'a> {
753755 for impl_item in items {
754756 self . ann . nested ( self , Nested :: ImplItem ( impl_item. id ) ) ;
755757 }
756- self . bclose ( item . span ) ;
758+ self . bclose ( span) ;
757759 }
758760 hir:: ItemKind :: Trait ( is_auto, unsafety, ref generics, ref bounds, trait_items) => {
759761 self . head ( "" ) ;
@@ -780,7 +782,7 @@ impl<'a> State<'a> {
780782 for trait_item in trait_items {
781783 self . ann . nested ( self , Nested :: TraitItem ( trait_item. id ) ) ;
782784 }
783- self . bclose ( item . span ) ;
785+ self . bclose ( span) ;
784786 }
785787 hir:: ItemKind :: TraitAlias ( ref generics, ref bounds) => {
786788 self . head ( "" ) ;
@@ -961,9 +963,10 @@ impl<'a> State<'a> {
961963 }
962964
963965 pub fn print_trait_item ( & mut self , ti : & hir:: TraitItem < ' _ > ) {
966+ let span = self . span ( ti. hir_id ) ;
964967 self . ann . pre ( self , AnnNode :: SubItem ( ti. hir_id ) ) ;
965968 self . hardbreak_if_not_bol ( ) ;
966- self . maybe_print_comment ( ti . span . lo ( ) ) ;
969+ self . maybe_print_comment ( span. lo ( ) ) ;
967970 self . print_outer_attributes ( & ti. attrs ) ;
968971 match ti. kind {
969972 hir:: TraitItemKind :: Const ( ref ty, default) => {
@@ -1000,9 +1003,10 @@ impl<'a> State<'a> {
10001003 }
10011004
10021005 pub fn print_impl_item ( & mut self , ii : & hir:: ImplItem < ' _ > ) {
1006+ let span = self . span ( ii. hir_id ) ;
10031007 self . ann . pre ( self , AnnNode :: SubItem ( ii. hir_id ) ) ;
10041008 self . hardbreak_if_not_bol ( ) ;
1005- self . maybe_print_comment ( ii . span . lo ( ) ) ;
1009+ self . maybe_print_comment ( span. lo ( ) ) ;
10061010 self . print_outer_attributes ( & ii. attrs ) ;
10071011 self . print_defaultness ( ii. defaultness ) ;
10081012
0 commit comments