Skip to content

Commit 67259e7

Browse files
committed
Extract constant MARGIN out of Printer struct
1 parent 24b8bb1 commit 67259e7

File tree

1 file changed

+6
-7
lines changed
  • compiler/rustc_ast_pretty/src

1 file changed

+6
-7
lines changed

compiler/rustc_ast_pretty/src/pp.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ enum PrintFrame {
199199

200200
const SIZE_INFINITY: isize = 0xffff;
201201

202+
/// Target line width.
203+
const MARGIN: isize = 78;
204+
202205
pub struct Printer {
203206
out: String,
204-
/// Width of lines we're constrained to
205-
margin: isize,
206207
/// Number of spaces left on line
207208
space: isize,
208209
/// Ring-buffer of tokens and calculated sizes
@@ -237,11 +238,9 @@ struct BufEntry {
237238

238239
impl Printer {
239240
pub fn new() -> Self {
240-
let linewidth = 78;
241241
Printer {
242242
out: String::new(),
243-
margin: linewidth as isize,
244-
space: linewidth as isize,
243+
space: MARGIN,
245244
buf: RingBuffer::new(),
246245
left_total: 0,
247246
right_total: 0,
@@ -395,7 +394,7 @@ impl Printer {
395394
self.print_stack.push(PrintFrame::Broken { indent: self.indent, breaks: token.breaks });
396395
self.indent = match token.indent {
397396
IndentStyle::Block { offset } => (self.indent as isize + offset) as usize,
398-
IndentStyle::Visual => (self.margin - self.space) as usize,
397+
IndentStyle::Visual => (MARGIN - self.space) as usize,
399398
};
400399
} else {
401400
self.print_stack.push(PrintFrame::Fits);
@@ -421,7 +420,7 @@ impl Printer {
421420
self.out.push('\n');
422421
let indent = self.indent as isize + token.offset;
423422
self.pending_indentation = indent;
424-
self.space = self.margin - indent;
423+
self.space = MARGIN - indent;
425424
}
426425
}
427426

0 commit comments

Comments
 (0)