1- use rustc_ast:: ast:: { self , BindingMode , ByRef , Pat , PatField , PatKind , RangeEnd , RangeSyntax } ;
1+ use rustc_ast:: ast:: { self , BindingMode , ByRef , Pat , PatField , PatKind } ;
22use rustc_span:: { BytePos , Span } ;
33
44use crate :: comment:: { FindUncommented , combine_strs_with_missing_comments} ;
@@ -11,7 +11,6 @@ use crate::lists::{
1111} ;
1212use crate :: macros:: { MacroPosition , rewrite_macro} ;
1313use crate :: overflow;
14- use crate :: pairs:: { PairParts , rewrite_pair} ;
1514use crate :: range:: rewrite_range;
1615use crate :: rewrite:: { Rewrite , RewriteContext , RewriteError , RewriteErrorExt , RewriteResult } ;
1716use crate :: shape:: Shape ;
@@ -79,24 +78,6 @@ fn is_short_pattern_inner(context: &RewriteContext<'_>, pat: &ast::Pat) -> bool
7978 }
8079}
8180
82- pub ( crate ) struct RangeOperand < ' a , T > {
83- pub operand : & ' a Option < Box < T > > ,
84- pub span : Span ,
85- }
86-
87- impl < ' a , T : Rewrite > Rewrite for RangeOperand < ' a , T > {
88- fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
89- self . rewrite_result ( context, shape) . ok ( )
90- }
91-
92- fn rewrite_result ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> RewriteResult {
93- match & self . operand {
94- None => Ok ( "" . to_owned ( ) ) ,
95- Some ( ref exp) => exp. rewrite_result ( context, shape) ,
96- }
97- }
98- }
99-
10081impl Rewrite for Pat {
10182 fn rewrite ( & self , context : & RewriteContext < ' _ > , shape : Shape ) -> Option < String > {
10283 self . rewrite_result ( context, shape) . ok ( )
@@ -362,50 +343,6 @@ impl Rewrite for Pat {
362343 }
363344}
364345
365- pub ( crate ) fn rewrite_range_pat < T : Rewrite > (
366- context : & RewriteContext < ' _ > ,
367- shape : Shape ,
368- lhs : & Option < Box < T > > ,
369- rhs : & Option < Box < T > > ,
370- end_kind : & rustc_span:: source_map:: Spanned < RangeEnd > ,
371- span : Span ,
372- ) -> RewriteResult {
373- let infix = match end_kind. node {
374- RangeEnd :: Included ( RangeSyntax :: DotDotDot ) => "..." ,
375- RangeEnd :: Included ( RangeSyntax :: DotDotEq ) => "..=" ,
376- RangeEnd :: Excluded => ".." ,
377- } ;
378- let infix = if context. config . spaces_around_ranges ( ) {
379- let lhs_spacing = match lhs {
380- None => "" ,
381- Some ( _) => " " ,
382- } ;
383- let rhs_spacing = match rhs {
384- None => "" ,
385- Some ( _) => " " ,
386- } ;
387- format ! ( "{lhs_spacing}{infix}{rhs_spacing}" )
388- } else {
389- infix. to_owned ( )
390- } ;
391- let lspan = span. with_hi ( end_kind. span . lo ( ) ) ;
392- let rspan = span. with_lo ( end_kind. span . hi ( ) ) ;
393- rewrite_pair (
394- & RangeOperand {
395- operand : lhs,
396- span : lspan,
397- } ,
398- & RangeOperand {
399- operand : rhs,
400- span : rspan,
401- } ,
402- PairParts :: infix ( & infix) ,
403- context,
404- shape,
405- SeparatorPlace :: Front ,
406- )
407- }
408-
409346fn rewrite_struct_pat (
410347 qself : & Option < Box < ast:: QSelf > > ,
411348 path : & ast:: Path ,
0 commit comments