1
Fork 0

sess: stabilize --terminal-width

Formerly `-Zterminal-width`, `--terminal-width` allows the user or build
tool to inform rustc of the width of the terminal so that diagnostics
can be truncated.

Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
David Wood 2022-02-14 06:01:38 +00:00
parent 5b8cf49c51
commit e5288842fa
13 changed files with 66 additions and 11 deletions

View file

@ -726,6 +726,7 @@ impl Default for Options {
prints: Vec::new(),
cg: Default::default(),
error_format: ErrorOutputType::default(),
terminal_width: None,
externs: Externs(BTreeMap::new()),
crate_name: None,
libs: Vec::new(),
@ -1427,6 +1428,12 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
never = never colorize output",
"auto|always|never",
),
opt::opt_s(
"",
"terminal-width",
"Inform rustc of the width of the terminal so that errors can be truncated",
"WIDTH",
),
opt::multi_s(
"",
"remap-path-prefix",
@ -2202,6 +2209,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let error_format = parse_error_format(matches, color, json_rendered);
let terminal_width = matches.opt_get("terminal-width").unwrap_or_else(|_| {
early_error(error_format, "`--terminal-width` must be an positive integer");
});
let unparsed_crate_types = matches.opt_strs("crate-type");
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
.unwrap_or_else(|e| early_error(error_format, &e));
@ -2474,6 +2485,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
prints,
cg,
error_format,
terminal_width,
externs,
unstable_features: UnstableFeatures::from_environment(crate_name.as_deref()),
crate_name,

View file

@ -170,6 +170,7 @@ top_level_options!(
test: bool [TRACKED],
error_format: ErrorOutputType [UNTRACKED],
terminal_width: Option<usize> [UNTRACKED],
/// If `Some`, enable incremental compilation, using the given
/// directory to store intermediate results.

View file

@ -1162,7 +1162,7 @@ fn default_emitter(
fallback_bundle,
short,
sopts.debugging_opts.teach,
sopts.debugging_opts.terminal_width,
sopts.terminal_width,
macro_backtrace,
),
Some(dst) => EmitterWriter::new(
@ -1188,7 +1188,7 @@ fn default_emitter(
fallback_bundle,
pretty,
json_rendered,
sopts.debugging_opts.terminal_width,
sopts.terminal_width,
macro_backtrace,
)
.ui_testing(sopts.debugging_opts.ui_testing),
@ -1202,7 +1202,7 @@ fn default_emitter(
fallback_bundle,
pretty,
json_rendered,
sopts.debugging_opts.terminal_width,
sopts.terminal_width,
macro_backtrace,
)
.ui_testing(sopts.debugging_opts.ui_testing),