11use  crate :: pp:: Breaks :: Inconsistent ; 
2- use  crate :: pprust:: state:: { AnnNode ,  PrintState ,  State } ; 
2+ use  crate :: pprust:: state:: delimited:: IterDelimited ; 
3+ use  crate :: pprust:: state:: { AnnNode ,  PrintState ,  State ,  INDENT_UNIT } ; 
34
45use  rustc_ast as  ast; 
56use  rustc_ast:: GenericBound ; 
@@ -138,11 +139,10 @@ impl<'a> State<'a> {
138139                self . end ( ) ;  // end outer head-block 
139140            } 
140141            ast:: ItemKind :: Use ( ref  tree)  => { 
141-                 self . head ( visibility_qualified ( & item. vis ,  "use" ) ) ; 
142+                 self . print_visibility ( & item. vis ) ; 
143+                 self . word_nbsp ( "use" ) ; 
142144                self . print_use_tree ( tree) ; 
143145                self . word ( ";" ) ; 
144-                 self . end ( ) ;  // end inner head-block 
145-                 self . end ( ) ;  // end outer head-block 
146146            } 
147147            ast:: ItemKind :: Static ( ref  ty,  mutbl,  ref  body)  => { 
148148                let  def = ast:: Defaultness :: Final ; 
@@ -615,8 +615,8 @@ impl<'a> State<'a> {
615615            ast:: UseTreeKind :: Simple ( rename,  ..)  => { 
616616                self . print_path ( & tree. prefix ,  false ,  0 ) ; 
617617                if  let  Some ( rename)  = rename { 
618-                     self . space ( ) ; 
619-                     self . word_space ( "as" ) ; 
618+                     self . nbsp ( ) ; 
619+                     self . word_nbsp ( "as" ) ; 
620620                    self . print_ident ( rename) ; 
621621                } 
622622            } 
@@ -628,16 +628,36 @@ impl<'a> State<'a> {
628628                self . word ( "*" ) ; 
629629            } 
630630            ast:: UseTreeKind :: Nested ( ref  items)  => { 
631-                 if  tree. prefix . segments . is_empty ( )  { 
632-                     self . word ( "{" ) ; 
633-                 }  else  { 
631+                 if  !tree. prefix . segments . is_empty ( )  { 
634632                    self . print_path ( & tree. prefix ,  false ,  0 ) ; 
635-                     self . word ( "::{" ) ; 
633+                     self . word ( "::" ) ; 
634+                 } 
635+                 if  items. is_empty ( )  { 
636+                     self . word ( "{}" ) ; 
637+                 }  else  if  items. len ( )  == 1  { 
638+                     self . print_use_tree ( & items[ 0 ] . 0 ) ; 
639+                 }  else  { 
640+                     self . cbox ( INDENT_UNIT ) ; 
641+                     self . word ( "{" ) ; 
642+                     self . zerobreak ( ) ; 
643+                     self . ibox ( 0 ) ; 
644+                     for  use_tree in  items. iter ( ) . delimited ( )  { 
645+                         self . print_use_tree ( & use_tree. 0 ) ; 
646+                         if  !use_tree. is_last  { 
647+                             self . word ( "," ) ; 
648+                             if  let  ast:: UseTreeKind :: Nested ( _)  = use_tree. 0 . kind  { 
649+                                 self . hardbreak ( ) ; 
650+                             }  else  { 
651+                                 self . space ( ) ; 
652+                             } 
653+                         } 
654+                     } 
655+                     self . end ( ) ; 
656+                     self . trailing_comma ( ) ; 
657+                     self . offset ( -INDENT_UNIT ) ; 
658+                     self . word ( "}" ) ; 
659+                     self . end ( ) ; 
636660                } 
637-                 self . commasep ( Inconsistent ,  & items,  |this,  & ( ref  tree,  _) | { 
638-                     this. print_use_tree ( tree) 
639-                 } ) ; 
640-                 self . word ( "}" ) ; 
641661            } 
642662        } 
643663    } 
0 commit comments