about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2022-01-31 10:56:57 -0800
committerDavid Tolnay <dtolnay@gmail.com>2022-01-31 10:56:57 -0800
commit6db97b35d8b39c13fb145c930250a5682780e4a5 (patch)
tree351353b6264c8fccba817f4f804785876fc5f428
parent67259e74a480c8bccc5a6f0c25c3b98c47be9f1d (diff)
downloadrust-6db97b35d8b39c13fb145c930250a5682780e4a5.tar.gz
rust-6db97b35d8b39c13fb145c930250a5682780e4a5.zip
Allow any line to have at least 60 chars
-rw-r--r--compiler/rustc_ast_pretty/src/pp.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs
index 3e1b6e35170..26d600cefc7 100644
--- a/compiler/rustc_ast_pretty/src/pp.rs
+++ b/compiler/rustc_ast_pretty/src/pp.rs
@@ -136,6 +136,7 @@ mod ring;
 
 use ring::RingBuffer;
 use std::borrow::Cow;
+use std::cmp;
 use std::collections::VecDeque;
 use std::iter;
 
@@ -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,
@@ -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);
         }
     }