Skip to content

Commit

Permalink
Allow any line to have at least 60 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 31, 2022
1 parent 67259e7 commit 6db97b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_ast_pretty/src/pp.rs
Expand Up @@ -136,6 +136,7 @@ mod ring;

use ring::RingBuffer;
use std::borrow::Cow;
use std::cmp;
use std::collections::VecDeque;
use std::iter;

Expand Down Expand Up @@ -201,6 +202,8 @@ const SIZE_INFINITY: isize = 0xffff;

/// Target line width.
const MARGIN: isize = 78;
/// Every line is allowed at least this much space, even if highly indented.
const MIN_SPACE: isize = 60;

pub struct Printer {
out: String,
Expand Down Expand Up @@ -420,7 +423,7 @@ impl Printer {
self.out.push('\n');
let indent = self.indent as isize + token.offset;
self.pending_indentation = indent;
self.space = MARGIN - indent;
self.space = cmp::max(MARGIN - indent, MIN_SPACE);
}
}

Expand Down

0 comments on commit 6db97b3

Please sign in to comment.