@@ -88,13 +88,6 @@ pub struct State<'a> {
88
88
comments : Option < Comments < ' a > > ,
89
89
ann : & ' a ( dyn PpAnn + ' a ) ,
90
90
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 ,
98
91
}
99
92
100
93
crate const INDENT_UNIT : usize = 4 ;
@@ -115,7 +108,6 @@ pub fn print_crate<'a>(
115
108
comments : Some ( Comments :: new ( sm, filename, input) ) ,
116
109
ann,
117
110
is_expanded,
118
- insert_extra_parens : true ,
119
111
} ;
120
112
121
113
if is_expanded && !krate. attrs . iter ( ) . any ( |attr| attr. has_name ( sym:: no_core) ) {
@@ -235,7 +227,6 @@ impl std::ops::DerefMut for State<'_> {
235
227
}
236
228
237
229
pub trait PrintState < ' a > : std:: ops:: Deref < Target = pp:: Printer > + std:: ops:: DerefMut {
238
- fn insert_extra_parens ( & self ) -> bool ;
239
230
fn comments ( & mut self ) -> & mut Option < Comments < ' a > > ;
240
231
fn print_ident ( & mut self , ident : Ident ) ;
241
232
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
819
810
820
811
fn to_string ( & self , f : impl FnOnce ( & mut State < ' _ > ) ) -> String {
821
812
let mut printer = State :: new ( ) ;
822
- printer. insert_extra_parens = self . insert_extra_parens ( ) ;
823
813
f ( & mut printer) ;
824
814
printer. s . eof ( )
825
815
}
826
816
}
827
817
828
818
impl < ' a > PrintState < ' a > for State < ' a > {
829
- fn insert_extra_parens ( & self ) -> bool {
830
- self . insert_extra_parens
831
- }
832
819
fn comments ( & mut self ) -> & mut Option < Comments < ' a > > {
833
820
& mut self . comments
834
821
}
@@ -865,17 +852,7 @@ impl<'a> PrintState<'a> for State<'a> {
865
852
866
853
impl < ' a > State < ' a > {
867
854
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 }
879
856
}
880
857
881
858
// Synthesizes a comment that was not textually present in the original source
@@ -1680,8 +1657,7 @@ impl<'a> State<'a> {
1680
1657
}
1681
1658
1682
1659
/// 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 ) {
1685
1661
if needs_par {
1686
1662
self . popen ( ) ;
1687
1663
}
0 commit comments