@@ -195,7 +195,11 @@ impl FixupContext {
195195 ///
196196 /// Not every expression has a leftmost subexpression. For example neither
197197 /// `-$a` nor `[$a]` have one.
198- pub fn leftmost_subexpression ( self ) -> Self {
198+ pub fn leftmost_subexpression_with_operator (
199+ self ,
200+ #[ cfg( feature = "full" ) ] next_operator_can_begin_expr : bool ,
201+ next_operator_can_begin_generics : bool ,
202+ ) -> Self {
199203 FixupContext {
200204 #[ cfg( feature = "full" ) ]
201205 stmt : false ,
@@ -209,10 +213,10 @@ impl FixupContext {
209213 #[ cfg( feature = "full" ) ]
210214 rightmost_subexpression : false ,
211215 #[ cfg( feature = "full" ) ]
212- next_operator_can_begin_expr : false ,
216+ next_operator_can_begin_expr,
213217 #[ cfg( feature = "full" ) ]
214218 next_operator_can_continue_expr : true ,
215- next_operator_can_begin_generics : false ,
219+ next_operator_can_begin_generics,
216220 ..self
217221 }
218222 }
@@ -242,22 +246,6 @@ impl FixupContext {
242246 }
243247 }
244248
245- /// Transform this fixup into the one that should apply when printing a
246- /// leftmost subexpression followed by punctuation that is legal as the
247- /// first token of an expression.
248- pub fn leftmost_subexpression_with_operator (
249- self ,
250- #[ cfg( feature = "full" ) ] next_operator_can_begin_expr : bool ,
251- next_operator_can_begin_generics : bool ,
252- ) -> Self {
253- FixupContext {
254- #[ cfg( feature = "full" ) ]
255- next_operator_can_begin_expr,
256- next_operator_can_begin_generics,
257- ..self . leftmost_subexpression ( )
258- }
259- }
260-
261249 /// Transform this fixup into the one that should apply when printing the
262250 /// rightmost subexpression of the current expression.
263251 ///
@@ -393,10 +381,14 @@ fn test_leftmost_rightmost_invariant() {
393381 } ;
394382 assert_eq ! ( i, BITS ) ;
395383 assert_eq ! (
396- fixup. leftmost_subexpression( ) . rightmost_subexpression( ) ,
384+ fixup
385+ . leftmost_subexpression_with_operator( false , false )
386+ . rightmost_subexpression( ) ,
397387 FixupContext {
398388 rightmost_subexpression: true ,
399- ..fixup. rightmost_subexpression( ) . leftmost_subexpression( )
389+ ..fixup
390+ . rightmost_subexpression( )
391+ . leftmost_subexpression_with_operator( false , false )
400392 } ,
401393 ) ;
402394 }
0 commit comments