@@ -446,7 +446,6 @@ impl std::ops::DerefMut for State<'_> {
446
446
}
447
447
448
448
pub trait PrintState < ' a > : std:: ops:: Deref < Target =pp:: Printer > + std:: ops:: DerefMut {
449
- fn writer ( & mut self ) -> & mut pp:: Printer ;
450
449
fn comments ( & mut self ) -> & mut Option < Comments < ' a > > ;
451
450
452
451
fn commasep < T , F > ( & mut self , b : Breaks , elts : & [ T ] , mut op : F )
@@ -476,51 +475,51 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
476
475
match cmnt. style {
477
476
comments:: Mixed => {
478
477
assert_eq ! ( cmnt. lines. len( ) , 1 ) ;
479
- self . writer ( ) . zerobreak ( ) ;
480
- self . writer ( ) . word ( cmnt. lines [ 0 ] . clone ( ) ) ;
481
- self . writer ( ) . zerobreak ( )
478
+ self . zerobreak ( ) ;
479
+ self . word ( cmnt. lines [ 0 ] . clone ( ) ) ;
480
+ self . zerobreak ( )
482
481
}
483
482
comments:: Isolated => {
484
483
self . hardbreak_if_not_bol ( ) ;
485
484
for line in & cmnt. lines {
486
485
// Don't print empty lines because they will end up as trailing
487
486
// whitespace
488
487
if !line. is_empty ( ) {
489
- self . writer ( ) . word ( line. clone ( ) ) ;
488
+ self . word ( line. clone ( ) ) ;
490
489
}
491
- self . writer ( ) . hardbreak ( ) ;
490
+ self . hardbreak ( ) ;
492
491
}
493
492
}
494
493
comments:: Trailing => {
495
- if !self . writer ( ) . is_beginning_of_line ( ) {
496
- self . writer ( ) . word ( " " ) ;
494
+ if !self . is_beginning_of_line ( ) {
495
+ self . word ( " " ) ;
497
496
}
498
497
if cmnt. lines . len ( ) == 1 {
499
- self . writer ( ) . word ( cmnt. lines [ 0 ] . clone ( ) ) ;
500
- self . writer ( ) . hardbreak ( )
498
+ self . word ( cmnt. lines [ 0 ] . clone ( ) ) ;
499
+ self . hardbreak ( )
501
500
} else {
502
501
self . ibox ( 0 ) ;
503
502
for line in & cmnt. lines {
504
503
if !line. is_empty ( ) {
505
- self . writer ( ) . word ( line. clone ( ) ) ;
504
+ self . word ( line. clone ( ) ) ;
506
505
}
507
- self . writer ( ) . hardbreak ( ) ;
506
+ self . hardbreak ( ) ;
508
507
}
509
508
self . end ( ) ;
510
509
}
511
510
}
512
511
comments:: BlankLine => {
513
512
// We need to do at least one, possibly two hardbreaks.
514
- let twice = match self . writer ( ) . last_token ( ) {
513
+ let twice = match self . last_token ( ) {
515
514
pp:: Token :: String ( s) => ";" == s,
516
515
pp:: Token :: Begin ( _) => true ,
517
516
pp:: Token :: End => true ,
518
517
_ => false
519
518
} ;
520
519
if twice {
521
- self . writer ( ) . hardbreak ( ) ;
520
+ self . hardbreak ( ) ;
522
521
}
523
- self . writer ( ) . hardbreak ( ) ;
522
+ self . hardbreak ( ) ;
524
523
}
525
524
}
526
525
if let Some ( cm) = self . comments ( ) {
@@ -534,7 +533,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
534
533
535
534
fn print_literal ( & mut self , lit : & ast:: Lit ) {
536
535
self . maybe_print_comment ( lit. span . lo ( ) ) ;
537
- self . writer ( ) . word ( lit. token . to_string ( ) )
536
+ self . word ( lit. token . to_string ( ) )
538
537
}
539
538
540
539
fn print_string ( & mut self , st : & str ,
@@ -549,7 +548,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
549
548
string=st) )
550
549
}
551
550
} ;
552
- self . writer ( ) . word ( st)
551
+ self . word ( st)
553
552
}
554
553
555
554
fn print_inner_attributes ( & mut self ,
@@ -601,10 +600,10 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
601
600
fn print_attribute_path ( & mut self , path : & ast:: Path ) {
602
601
for ( i, segment) in path. segments . iter ( ) . enumerate ( ) {
603
602
if i > 0 {
604
- self . writer ( ) . word ( "::" ) ;
603
+ self . word ( "::" ) ;
605
604
}
606
605
if segment. ident . name != kw:: PathRoot {
607
- self . writer ( ) . word ( ident_to_string ( segment. ident , segment. ident . is_raw_guess ( ) ) ) ;
606
+ self . word ( ident_to_string ( segment. ident , segment. ident . is_raw_guess ( ) ) ) ;
608
607
}
609
608
}
610
609
}
@@ -620,21 +619,21 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
620
619
}
621
620
self . maybe_print_comment ( attr. span . lo ( ) ) ;
622
621
if attr. is_sugared_doc {
623
- self . writer ( ) . word ( attr. value_str ( ) . unwrap ( ) . as_str ( ) . to_string ( ) ) ;
624
- self . writer ( ) . hardbreak ( )
622
+ self . word ( attr. value_str ( ) . unwrap ( ) . as_str ( ) . to_string ( ) ) ;
623
+ self . hardbreak ( )
625
624
} else {
626
625
match attr. style {
627
- ast:: AttrStyle :: Inner => self . writer ( ) . word ( "#![" ) ,
628
- ast:: AttrStyle :: Outer => self . writer ( ) . word ( "#[" ) ,
626
+ ast:: AttrStyle :: Inner => self . word ( "#![" ) ,
627
+ ast:: AttrStyle :: Outer => self . word ( "#[" ) ,
629
628
}
630
629
if let Some ( mi) = attr. meta ( ) {
631
630
self . print_meta_item ( & mi) ;
632
631
} else {
633
632
self . print_attribute_path ( & attr. path ) ;
634
- self . writer ( ) . space ( ) ;
633
+ self . space ( ) ;
635
634
self . print_tts ( attr. tokens . clone ( ) ) ;
636
635
}
637
- self . writer ( ) . word ( "]" ) ;
636
+ self . word ( "]" ) ;
638
637
}
639
638
}
640
639
@@ -655,7 +654,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
655
654
ast:: MetaItemKind :: Word => self . print_attribute_path ( & item. path ) ,
656
655
ast:: MetaItemKind :: NameValue ( ref value) => {
657
656
self . print_attribute_path ( & item. path ) ;
658
- self . writer ( ) . space ( ) ;
657
+ self . space ( ) ;
659
658
self . word_space ( "=" ) ;
660
659
self . print_literal ( value) ;
661
660
}
@@ -681,20 +680,20 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
681
680
fn print_tt ( & mut self , tt : tokenstream:: TokenTree , convert_dollar_crate : bool ) {
682
681
match tt {
683
682
TokenTree :: Token ( ref token) => {
684
- self . writer ( ) . word ( token_to_string_ext ( & token, convert_dollar_crate) ) ;
683
+ self . word ( token_to_string_ext ( & token, convert_dollar_crate) ) ;
685
684
match token. kind {
686
685
token:: DocComment ( ..) => {
687
- self . writer ( ) . hardbreak ( )
686
+ self . hardbreak ( )
688
687
}
689
688
_ => { }
690
689
}
691
690
}
692
691
TokenTree :: Delimited ( _, delim, tts) => {
693
- self . writer ( ) . word ( token_kind_to_string ( & token:: OpenDelim ( delim) ) ) ;
694
- self . writer ( ) . space ( ) ;
692
+ self . word ( token_kind_to_string ( & token:: OpenDelim ( delim) ) ) ;
693
+ self . space ( ) ;
695
694
self . print_tts ( tts) ;
696
- self . writer ( ) . space ( ) ;
697
- self . writer ( ) . word ( token_kind_to_string ( & token:: CloseDelim ( delim) ) )
695
+ self . space ( ) ;
696
+ self . word ( token_kind_to_string ( & token:: CloseDelim ( delim) ) )
698
697
} ,
699
698
}
700
699
}
@@ -707,7 +706,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
707
706
self . ibox ( 0 ) ;
708
707
for ( i, tt) in tts. into_trees ( ) . enumerate ( ) {
709
708
if i != 0 {
710
- self . writer ( ) . space ( ) ;
709
+ self . space ( ) ;
711
710
}
712
711
self . print_tt ( tt, convert_dollar_crate) ;
713
712
}
@@ -716,10 +715,6 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
716
715
}
717
716
718
717
impl < ' a > PrintState < ' a > for State < ' a > {
719
- fn writer ( & mut self ) -> & mut pp:: Printer {
720
- & mut self . s
721
- }
722
-
723
718
fn comments ( & mut self ) -> & mut Option < Comments < ' a > > {
724
719
& mut self . comments
725
720
}
0 commit comments