@@ -96,8 +96,7 @@ impl<'a> PrintState<'a> for State<'a> {
96
96
}
97
97
}
98
98
99
- #[ allow( non_upper_case_globals) ]
100
- pub const indent_unit: usize = 4 ;
99
+ pub const INDENT_UNIT : usize = 4 ;
101
100
102
101
/// Requires you to pass an input filename and reader so that
103
102
/// it can scan the input text for comments to copy forward.
@@ -168,7 +167,7 @@ impl<'a> State<'a> {
168
167
pub fn head < S : Into < Cow < ' static , str > > > ( & mut self , w : S ) {
169
168
let w = w. into ( ) ;
170
169
// outer-box is consistent
171
- self . cbox ( indent_unit ) ;
170
+ self . cbox ( INDENT_UNIT ) ;
172
171
// head-box is inconsistent
173
172
self . ibox ( w. len ( ) + 1 ) ;
174
173
// keyword that starts the head
@@ -196,7 +195,7 @@ impl<'a> State<'a> {
196
195
}
197
196
198
197
pub fn bclose ( & mut self , span : syntax_pos:: Span ) {
199
- self . bclose_maybe_open ( span, indent_unit , true )
198
+ self . bclose_maybe_open ( span, INDENT_UNIT , true )
200
199
}
201
200
202
201
pub fn space_if_not_bol ( & mut self ) {
@@ -732,7 +731,7 @@ impl<'a> State<'a> {
732
731
self . space_if_not_bol ( ) ;
733
732
self . maybe_print_comment ( v. span . lo ( ) ) ;
734
733
self . print_outer_attributes ( & v. node . attrs ) ;
735
- self . ibox ( indent_unit ) ;
734
+ self . ibox ( INDENT_UNIT ) ;
736
735
self . print_variant ( v) ;
737
736
self . s . word ( "," ) ;
738
737
self . end ( ) ;
@@ -919,10 +918,10 @@ impl<'a> State<'a> {
919
918
decl : impl Fn ( & mut Self )
920
919
) {
921
920
self . space_if_not_bol ( ) ;
922
- self . ibox ( indent_unit ) ;
921
+ self . ibox ( INDENT_UNIT ) ;
923
922
self . word_nbsp ( "let" ) ;
924
923
925
- self . ibox ( indent_unit ) ;
924
+ self . ibox ( INDENT_UNIT ) ;
926
925
decl ( self ) ;
927
926
self . end ( ) ;
928
927
@@ -964,7 +963,7 @@ impl<'a> State<'a> {
964
963
}
965
964
966
965
pub fn print_block_unclosed ( & mut self , blk : & hir:: Block ) {
967
- self . print_block_unclosed_indent ( blk, indent_unit )
966
+ self . print_block_unclosed_indent ( blk, INDENT_UNIT )
968
967
}
969
968
970
969
pub fn print_block_unclosed_indent ( & mut self ,
@@ -978,7 +977,7 @@ impl<'a> State<'a> {
978
977
blk : & hir:: Block ,
979
978
attrs : & [ ast:: Attribute ] )
980
979
{
981
- self . print_block_maybe_unclosed ( blk, indent_unit , attrs, true )
980
+ self . print_block_maybe_unclosed ( blk, INDENT_UNIT , attrs, true )
982
981
}
983
982
984
983
pub fn print_block_maybe_unclosed ( & mut self ,
@@ -1055,15 +1054,15 @@ impl<'a> State<'a> {
1055
1054
}
1056
1055
1057
1056
fn print_expr_vec ( & mut self , exprs : & [ hir:: Expr ] ) {
1058
- self . ibox ( indent_unit ) ;
1057
+ self . ibox ( INDENT_UNIT ) ;
1059
1058
self . s . word ( "[" ) ;
1060
1059
self . commasep_exprs ( Inconsistent , exprs) ;
1061
1060
self . s . word ( "]" ) ;
1062
1061
self . end ( )
1063
1062
}
1064
1063
1065
1064
fn print_expr_repeat ( & mut self , element : & hir:: Expr , count : & hir:: AnonConst ) {
1066
- self . ibox ( indent_unit ) ;
1065
+ self . ibox ( INDENT_UNIT ) ;
1067
1066
self . s . word ( "[" ) ;
1068
1067
self . print_expr ( element) ;
1069
1068
self . word_space ( ";" ) ;
@@ -1082,7 +1081,7 @@ impl<'a> State<'a> {
1082
1081
self . commasep_cmnt ( Consistent ,
1083
1082
& fields[ ..] ,
1084
1083
|s, field| {
1085
- s. ibox ( indent_unit ) ;
1084
+ s. ibox ( INDENT_UNIT ) ;
1086
1085
if !field. is_shorthand {
1087
1086
s. print_ident ( field. ident ) ;
1088
1087
s. word_space ( ":" ) ;
@@ -1093,7 +1092,7 @@ impl<'a> State<'a> {
1093
1092
|f| f. span ) ;
1094
1093
match * wth {
1095
1094
Some ( ref expr) => {
1096
- self . ibox ( indent_unit ) ;
1095
+ self . ibox ( INDENT_UNIT ) ;
1097
1096
if !fields. is_empty ( ) {
1098
1097
self . s . word ( "," ) ;
1099
1098
self . s . space ( ) ;
@@ -1198,7 +1197,7 @@ impl<'a> State<'a> {
1198
1197
pub fn print_expr ( & mut self , expr : & hir:: Expr ) {
1199
1198
self . maybe_print_comment ( expr. span . lo ( ) ) ;
1200
1199
self . print_outer_attributes ( & expr. attrs ) ;
1201
- self . ibox ( indent_unit ) ;
1200
+ self . ibox ( INDENT_UNIT ) ;
1202
1201
self . ann . pre ( self , AnnNode :: Expr ( expr) ) ;
1203
1202
match expr. node {
1204
1203
hir:: ExprKind :: Box ( ref expr) => {
@@ -1250,7 +1249,7 @@ impl<'a> State<'a> {
1250
1249
}
1251
1250
hir:: ExprKind :: DropTemps ( ref init) => {
1252
1251
// Print `{`:
1253
- self . cbox ( indent_unit ) ;
1252
+ self . cbox ( INDENT_UNIT ) ;
1254
1253
self . ibox ( 0 ) ;
1255
1254
self . bopen ( ) ;
1256
1255
@@ -1264,7 +1263,7 @@ impl<'a> State<'a> {
1264
1263
self . print_ident ( temp) ;
1265
1264
1266
1265
// Print `}`:
1267
- self . bclose_maybe_open ( expr. span , indent_unit , true ) ;
1266
+ self . bclose_maybe_open ( expr. span , INDENT_UNIT , true ) ;
1268
1267
}
1269
1268
hir:: ExprKind :: Loop ( ref blk, opt_label, _) => {
1270
1269
if let Some ( label) = opt_label {
@@ -1276,7 +1275,7 @@ impl<'a> State<'a> {
1276
1275
self . print_block ( & blk) ;
1277
1276
}
1278
1277
hir:: ExprKind :: Match ( ref expr, ref arms, _) => {
1279
- self . cbox ( indent_unit ) ;
1278
+ self . cbox ( INDENT_UNIT ) ;
1280
1279
self . ibox ( 4 ) ;
1281
1280
self . word_nbsp ( "match" ) ;
1282
1281
self . print_expr_as_cond ( & expr) ;
@@ -1308,7 +1307,7 @@ impl<'a> State<'a> {
1308
1307
self . word_space ( ":" ) ;
1309
1308
}
1310
1309
// containing cbox, will be closed by print-block at }
1311
- self . cbox ( indent_unit ) ;
1310
+ self . cbox ( INDENT_UNIT ) ;
1312
1311
// head-box, will be closed by print-block after {
1313
1312
self . ibox ( 0 ) ;
1314
1313
self . print_block ( & blk) ;
@@ -1678,7 +1677,7 @@ impl<'a> State<'a> {
1678
1677
self . commasep_cmnt ( Consistent ,
1679
1678
& fields[ ..] ,
1680
1679
|s, f| {
1681
- s. cbox ( indent_unit ) ;
1680
+ s. cbox ( INDENT_UNIT ) ;
1682
1681
if !f. node . is_shorthand {
1683
1682
s. print_ident ( f. node . ident ) ;
1684
1683
s. word_nbsp ( ":" ) ;
@@ -1787,7 +1786,7 @@ impl<'a> State<'a> {
1787
1786
if arm. attrs . is_empty ( ) {
1788
1787
self . s . space ( ) ;
1789
1788
}
1790
- self . cbox ( indent_unit ) ;
1789
+ self . cbox ( INDENT_UNIT ) ;
1791
1790
self . ann . pre ( self , AnnNode :: Arm ( arm) ) ;
1792
1791
self . ibox ( 0 ) ;
1793
1792
self . print_outer_attributes ( & arm. attrs ) ;
@@ -1820,7 +1819,7 @@ impl<'a> State<'a> {
1820
1819
self . word_space ( ":" ) ;
1821
1820
}
1822
1821
// the block will close the pattern's ibox
1823
- self . print_block_unclosed_indent ( & blk, indent_unit ) ;
1822
+ self . print_block_unclosed_indent ( & blk, INDENT_UNIT ) ;
1824
1823
1825
1824
// If it is a user-provided unsafe block, print a comma after it
1826
1825
if let hir:: UnsafeBlock ( hir:: UserProvided ) = blk. rules {
@@ -1859,7 +1858,7 @@ impl<'a> State<'a> {
1859
1858
// Make sure we aren't supplied *both* `arg_names` and `body_id`.
1860
1859
assert ! ( arg_names. is_empty( ) || body_id. is_none( ) ) ;
1861
1860
self . commasep ( Inconsistent , & decl. inputs , |s, ty| {
1862
- s. ibox ( indent_unit ) ;
1861
+ s. ibox ( INDENT_UNIT ) ;
1863
1862
if let Some ( arg_name) = arg_names. get ( i) {
1864
1863
s. s . word ( arg_name. as_str ( ) . to_string ( ) ) ;
1865
1864
s. s . word ( ":" ) ;
@@ -1886,7 +1885,7 @@ impl<'a> State<'a> {
1886
1885
self . s . word ( "|" ) ;
1887
1886
let mut i = 0 ;
1888
1887
self . commasep ( Inconsistent , & decl. inputs , |s, ty| {
1889
- s. ibox ( indent_unit ) ;
1888
+ s. ibox ( INDENT_UNIT ) ;
1890
1889
1891
1890
s. ann . nested ( s, Nested :: BodyArgPat ( body_id, i) ) ;
1892
1891
i += 1 ;
@@ -2085,7 +2084,7 @@ impl<'a> State<'a> {
2085
2084
}
2086
2085
2087
2086
self . space_if_not_bol ( ) ;
2088
- self . ibox ( indent_unit ) ;
2087
+ self . ibox ( INDENT_UNIT ) ;
2089
2088
self . word_space ( "->" ) ;
2090
2089
match decl. output {
2091
2090
hir:: DefaultReturn ( ..) => unreachable ! ( ) ,
@@ -2107,7 +2106,7 @@ impl<'a> State<'a> {
2107
2106
generic_params : & [ hir:: GenericParam ] ,
2108
2107
arg_names : & [ ast:: Ident ] )
2109
2108
{
2110
- self . ibox ( indent_unit ) ;
2109
+ self . ibox ( INDENT_UNIT ) ;
2111
2110
if !generic_params. is_empty ( ) {
2112
2111
self . s . word ( "for" ) ;
2113
2112
self . print_generic_params ( generic_params) ;
0 commit comments