diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-08-14 17:57:28 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-08-21 11:58:24 -0700 |
| commit | 21f2e9334567b64436f4e6525c5c98adafd16ca2 (patch) | |
| tree | 0e43136339829eaf74a710779a90f688e26ebb30 /src/librustc_errors | |
| parent | 9980796d6d29f532e9a49a5b3767285e2a5e2d02 (diff) | |
| download | rust-21f2e9334567b64436f4e6525c5c98adafd16ca2.tar.gz rust-21f2e9334567b64436f4e6525c5c98adafd16ca2.zip | |
Add terminal_width debugging flag
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 24 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 2 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 83c55c0da2b..77d373e7a8c 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -51,9 +51,11 @@ impl HumanReadableErrorType { dst: Box<dyn Write + Send>, source_map: Option<Lrc<SourceMapperDyn>>, teach: bool, + terminal_width: Option<usize>, ) -> EmitterWriter { let (short, color_config) = self.unzip(); - EmitterWriter::new(dst, source_map, short, teach, color_config.suggests_using_colors()) + let color = color_config.suggests_using_colors(); + EmitterWriter::new(dst, source_map, short, teach, color, terminal_width) } } @@ -296,6 +298,7 @@ pub struct EmitterWriter { short_message: bool, teach: bool, ui_testing: bool, + terminal_width: Option<usize>, } #[derive(Debug)] @@ -306,11 +309,13 @@ pub struct FileWithAnnotatedLines { } impl EmitterWriter { - pub fn stderr(color_config: ColorConfig, - source_map: Option<Lrc<SourceMapperDyn>>, - short_message: bool, - teach: bool) - -> EmitterWriter { + pub fn stderr( + color_config: ColorConfig, + source_map: Option<Lrc<SourceMapperDyn>>, + short_message: bool, + teach: bool, + terminal_width: Option<usize>, + ) -> EmitterWriter { let dst = Destination::from_stderr(color_config); EmitterWriter { dst, @@ -318,6 +323,7 @@ impl EmitterWriter { short_message, teach, ui_testing: false, + terminal_width, } } @@ -327,6 +333,7 @@ impl EmitterWriter { short_message: bool, teach: bool, colored: bool, + terminal_width: Option<usize>, ) -> EmitterWriter { EmitterWriter { dst: Raw(dst, colored), @@ -334,6 +341,7 @@ impl EmitterWriter { short_message, teach, ui_testing: false, + terminal_width, } } @@ -1295,7 +1303,9 @@ impl EmitterWriter { width_offset + annotated_file.multiline_depth + 1 }; - let column_width = if self.ui_testing { + let column_width = if let Some(width) = self.terminal_width { + width + } else if self.ui_testing { 140 } else { term_size::dimensions().map(|(w, _)| w - code_offset).unwrap_or(140) diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 4018a667bf2..6585633e00a 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -383,7 +383,7 @@ impl Handler { cm: Option<Lrc<SourceMapperDyn>>, flags: HandlerFlags) -> Handler { - let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false)); + let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false, None)); Handler::with_emitter_and_flags(emitter, flags) } |
