@@ -88,13 +88,6 @@ pub struct State<'a> {
8888 comments : Option < Comments < ' a > > ,
8989 ann : & ' a ( dyn PpAnn + ' a ) ,
9090 is_expanded : bool ,
91- // If `true`, additional parenthesis (separate from `ExprKind::Paren`)
92- // are inserted to ensure that proper precedence is preserved
93- // in the pretty-printed output.
94- //
95- // This is usually `true`, except when performing the pretty-print/reparse
96- // check in `nt_to_tokenstream`
97- insert_extra_parens : bool ,
9891}
9992
10093crate const INDENT_UNIT : usize = 4 ;
@@ -115,7 +108,6 @@ pub fn print_crate<'a>(
115108 comments : Some ( Comments :: new ( sm, filename, input) ) ,
116109 ann,
117110 is_expanded,
118- insert_extra_parens : true ,
119111 } ;
120112
121113 if is_expanded && !krate. attrs . iter ( ) . any ( |attr| attr. has_name ( sym:: no_core) ) {
@@ -235,7 +227,6 @@ impl std::ops::DerefMut for State<'_> {
235227}
236228
237229pub trait PrintState < ' a > : std:: ops:: Deref < Target = pp:: Printer > + std:: ops:: DerefMut {
238- fn insert_extra_parens ( & self ) -> bool ;
239230 fn comments ( & mut self ) -> & mut Option < Comments < ' a > > ;
240231 fn print_ident ( & mut self , ident : Ident ) ;
241232 fn print_generic_args ( & mut self , args : & ast:: GenericArgs , colons_before_params : bool ) ;
@@ -819,16 +810,12 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
819810
820811 fn to_string ( & self , f : impl FnOnce ( & mut State < ' _ > ) ) -> String {
821812 let mut printer = State :: new ( ) ;
822- printer. insert_extra_parens = self . insert_extra_parens ( ) ;
823813 f ( & mut printer) ;
824814 printer. s . eof ( )
825815 }
826816}
827817
828818impl < ' a > PrintState < ' a > for State < ' a > {
829- fn insert_extra_parens ( & self ) -> bool {
830- self . insert_extra_parens
831- }
832819 fn comments ( & mut self ) -> & mut Option < Comments < ' a > > {
833820 & mut self . comments
834821 }
@@ -865,17 +852,7 @@ impl<'a> PrintState<'a> for State<'a> {
865852
866853impl < ' a > State < ' a > {
867854 pub fn new ( ) -> State < ' a > {
868- State {
869- s : pp:: mk_printer ( ) ,
870- comments : None ,
871- ann : & NoAnn ,
872- is_expanded : false ,
873- insert_extra_parens : true ,
874- }
875- }
876-
877- pub ( super ) fn without_insert_extra_parens ( ) -> State < ' a > {
878- State { insert_extra_parens : false , ..State :: new ( ) }
855+ State { s : pp:: mk_printer ( ) , comments : None , ann : & NoAnn , is_expanded : false }
879856 }
880857
881858 // Synthesizes a comment that was not textually present in the original source
@@ -1680,8 +1657,7 @@ impl<'a> State<'a> {
16801657 }
16811658
16821659 /// Prints `expr` or `(expr)` when `needs_par` holds.
1683- fn print_expr_cond_paren ( & mut self , expr : & ast:: Expr , mut needs_par : bool ) {
1684- needs_par &= self . insert_extra_parens ;
1660+ fn print_expr_cond_paren ( & mut self , expr : & ast:: Expr , needs_par : bool ) {
16851661 if needs_par {
16861662 self . popen ( ) ;
16871663 }
0 commit comments