Skip to content

Commit 63fdf1a

Browse files
Remove needless indent arguments
We're always indenting by INDENT_UNIT anyway
1 parent daf1b29 commit 63fdf1a

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

src/librustc/hir/print.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,18 @@ impl<'a> State<'a> {
183183

184184
pub fn bclose_maybe_open(&mut self,
185185
span: syntax_pos::Span,
186-
indented: usize,
187186
close_box: bool)
188187
{
189188
self.maybe_print_comment(span.hi());
190-
self.break_offset_if_not_bol(1, -(indented as isize));
189+
self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
191190
self.s.word("}");
192191
if close_box {
193192
self.end(); // close the outer-box
194193
}
195194
}
196195

197196
pub fn bclose(&mut self, span: syntax_pos::Span) {
198-
self.bclose_maybe_open(span, INDENT_UNIT, true)
197+
self.bclose_maybe_open(span, true)
199198
}
200199

201200
pub fn space_if_not_bol(&mut self) {
@@ -963,26 +962,18 @@ impl<'a> State<'a> {
963962
}
964963

965964
pub fn print_block_unclosed(&mut self, blk: &hir::Block) {
966-
self.print_block_unclosed_indent(blk, INDENT_UNIT)
967-
}
968-
969-
pub fn print_block_unclosed_indent(&mut self,
970-
blk: &hir::Block,
971-
indented: usize)
972-
{
973-
self.print_block_maybe_unclosed(blk, indented, &[], false)
965+
self.print_block_maybe_unclosed(blk, &[], false)
974966
}
975967

976968
pub fn print_block_with_attrs(&mut self,
977969
blk: &hir::Block,
978970
attrs: &[ast::Attribute])
979971
{
980-
self.print_block_maybe_unclosed(blk, INDENT_UNIT, attrs, true)
972+
self.print_block_maybe_unclosed(blk, attrs, true)
981973
}
982974

983975
pub fn print_block_maybe_unclosed(&mut self,
984976
blk: &hir::Block,
985-
indented: usize,
986977
attrs: &[ast::Attribute],
987978
close_box: bool)
988979
{
@@ -1006,7 +997,7 @@ impl<'a> State<'a> {
1006997
self.print_expr(&expr);
1007998
self.maybe_print_trailing_comment(expr.span, Some(blk.span.hi()));
1008999
}
1009-
self.bclose_maybe_open(blk.span, indented, close_box);
1000+
self.bclose_maybe_open(blk.span, close_box);
10101001
self.ann.post(self, AnnNode::Block(blk))
10111002
}
10121003

@@ -1263,7 +1254,7 @@ impl<'a> State<'a> {
12631254
self.print_ident(temp);
12641255

12651256
// Print `}`:
1266-
self.bclose_maybe_open(expr.span, INDENT_UNIT, true);
1257+
self.bclose_maybe_open(expr.span, true);
12671258
}
12681259
hir::ExprKind::Loop(ref blk, opt_label, _) => {
12691260
if let Some(label) = opt_label {
@@ -1819,7 +1810,7 @@ impl<'a> State<'a> {
18191810
self.word_space(":");
18201811
}
18211812
// the block will close the pattern's ibox
1822-
self.print_block_unclosed_indent(&blk, INDENT_UNIT);
1813+
self.print_block_unclosed(&blk);
18231814

18241815
// If it is a user-provided unsafe block, print a comma after it
18251816
if let hir::UnsafeBlock(hir::UserProvided) = blk.rules {

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4591,7 +4591,7 @@ impl<'a> Parser<'a> {
45914591
s.ibox(INDENT_UNIT);
45924592
s.bopen();
45934593
s.print_stmt(&stmt);
4594-
s.bclose_maybe_open(stmt.span, INDENT_UNIT, false)
4594+
s.bclose_maybe_open(stmt.span, false)
45954595
});
45964596
e.span_suggestion(
45974597
stmt_span,

src/libsyntax/print/pprust.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -743,17 +743,16 @@ impl<'a> State<'a> {
743743
self.end(); // close the head-box
744744
}
745745

746-
crate fn bclose_maybe_open(&mut self, span: syntax_pos::Span,
747-
indented: usize, close_box: bool) {
746+
crate fn bclose_maybe_open(&mut self, span: syntax_pos::Span, close_box: bool) {
748747
self.maybe_print_comment(span.hi());
749-
self.break_offset_if_not_bol(1, -(indented as isize));
748+
self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize));
750749
self.s.word("}");
751750
if close_box {
752751
self.end(); // close the outer-box
753752
}
754753
}
755754
crate fn bclose(&mut self, span: syntax_pos::Span) {
756-
self.bclose_maybe_open(span, INDENT_UNIT, true)
755+
self.bclose_maybe_open(span, true)
757756
}
758757

759758
crate fn break_offset_if_not_bol(&mut self, n: usize,
@@ -1559,20 +1558,18 @@ impl<'a> State<'a> {
15591558
self.print_block_with_attrs(blk, &[])
15601559
}
15611560

1562-
crate fn print_block_unclosed_indent(&mut self, blk: &ast::Block,
1563-
indented: usize) {
1564-
self.print_block_maybe_unclosed(blk, indented, &[], false)
1561+
crate fn print_block_unclosed_indent(&mut self, blk: &ast::Block) {
1562+
self.print_block_maybe_unclosed(blk, &[], false)
15651563
}
15661564

15671565
crate fn print_block_with_attrs(&mut self,
15681566
blk: &ast::Block,
15691567
attrs: &[ast::Attribute]) {
1570-
self.print_block_maybe_unclosed(blk, INDENT_UNIT, attrs, true)
1568+
self.print_block_maybe_unclosed(blk, attrs, true)
15711569
}
15721570

15731571
crate fn print_block_maybe_unclosed(&mut self,
15741572
blk: &ast::Block,
1575-
indented: usize,
15761573
attrs: &[ast::Attribute],
15771574
close_box: bool) {
15781575
match blk.rules {
@@ -1597,7 +1594,7 @@ impl<'a> State<'a> {
15971594
}
15981595
}
15991596

1600-
self.bclose_maybe_open(blk.span, indented, close_box);
1597+
self.bclose_maybe_open(blk.span, close_box);
16011598
self.ann.post(self, AnnNode::Block(blk))
16021599
}
16031600

@@ -2519,7 +2516,7 @@ impl<'a> State<'a> {
25192516
}
25202517

25212518
// the block will close the pattern's ibox
2522-
self.print_block_unclosed_indent(blk, INDENT_UNIT);
2519+
self.print_block_unclosed_indent(blk);
25232520

25242521
// If it is a user-provided unsafe block, print a comma after it
25252522
if let BlockCheckMode::Unsafe(ast::UserProvided) = blk.rules {

0 commit comments

Comments
 (0)