Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emitter: column width defaults to 140 #73719

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ use std::path::Path;
use termcolor::{Ansi, BufferWriter, ColorChoice, ColorSpec, StandardStream};
use termcolor::{Buffer, Color, WriteColor};

/// Default column width, used in tests and when terminal dimensions cannot be determined.
const DEFAULT_COLUMN_WIDTH: usize = 140;

/// Describes the way the content of the `rendered` field of the json output is generated
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HumanReadableErrorType {
Expand Down Expand Up @@ -74,7 +77,8 @@ struct Margin {
pub computed_left: usize,
/// The end of the line to be displayed.
pub computed_right: usize,
/// The current width of the terminal. 140 by default and in tests.
/// The current width of the terminal. Uses value of `DEFAULT_COLUMN_WIDTH` constant by default
/// and in tests.
pub column_width: usize,
/// The end column of a span label, including the span. Doesn't account for labels not in the
/// same line as the span.
Expand Down Expand Up @@ -1414,11 +1418,11 @@ impl EmitterWriter {
let column_width = if let Some(width) = self.terminal_width {
width.saturating_sub(code_offset)
} else if self.ui_testing {
140
DEFAULT_COLUMN_WIDTH
} else {
termize::dimensions()
.map(|(w, _)| w.saturating_sub(code_offset))
.unwrap_or(usize::MAX)
.unwrap_or(DEFAULT_COLUMN_WIDTH)
};

let margin = Margin::new(
Expand Down