Skip to content

Commit cd23af6

Browse files
committed
session: terminal-width -> output-width
Rename the `--terminal-width` flag to `--output-width` as the behaviour doesn't just apply to terminals (and so is slightly less accurate). Signed-off-by: David Wood <[email protected]>
1 parent e528884 commit cd23af6

31 files changed

+65
-65
lines changed

Diff for: compiler/rustc_errors/src/emitter.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl HumanReadableErrorType {
6363
bundle: Option<Lrc<FluentBundle>>,
6464
fallback_bundle: LazyFallbackBundle,
6565
teach: bool,
66-
terminal_width: Option<usize>,
66+
output_width: Option<usize>,
6767
macro_backtrace: bool,
6868
) -> EmitterWriter {
6969
let (short, color_config) = self.unzip();
@@ -76,7 +76,7 @@ impl HumanReadableErrorType {
7676
short,
7777
teach,
7878
color,
79-
terminal_width,
79+
output_width,
8080
macro_backtrace,
8181
)
8282
}
@@ -710,7 +710,7 @@ pub struct EmitterWriter {
710710
short_message: bool,
711711
teach: bool,
712712
ui_testing: bool,
713-
terminal_width: Option<usize>,
713+
output_width: Option<usize>,
714714

715715
macro_backtrace: bool,
716716
}
@@ -730,7 +730,7 @@ impl EmitterWriter {
730730
fallback_bundle: LazyFallbackBundle,
731731
short_message: bool,
732732
teach: bool,
733-
terminal_width: Option<usize>,
733+
output_width: Option<usize>,
734734
macro_backtrace: bool,
735735
) -> EmitterWriter {
736736
let dst = Destination::from_stderr(color_config);
@@ -742,7 +742,7 @@ impl EmitterWriter {
742742
short_message,
743743
teach,
744744
ui_testing: false,
745-
terminal_width,
745+
output_width,
746746
macro_backtrace,
747747
}
748748
}
@@ -755,7 +755,7 @@ impl EmitterWriter {
755755
short_message: bool,
756756
teach: bool,
757757
colored: bool,
758-
terminal_width: Option<usize>,
758+
output_width: Option<usize>,
759759
macro_backtrace: bool,
760760
) -> EmitterWriter {
761761
EmitterWriter {
@@ -766,7 +766,7 @@ impl EmitterWriter {
766766
short_message,
767767
teach,
768768
ui_testing: false,
769-
terminal_width,
769+
output_width,
770770
macro_backtrace,
771771
}
772772
}
@@ -1615,7 +1615,7 @@ impl EmitterWriter {
16151615
width_offset + annotated_file.multiline_depth + 1
16161616
};
16171617

1618-
let column_width = if let Some(width) = self.terminal_width {
1618+
let column_width = if let Some(width) = self.output_width {
16191619
width.saturating_sub(code_offset)
16201620
} else if self.ui_testing {
16211621
DEFAULT_COLUMN_WIDTH

Diff for: compiler/rustc_errors/src/json.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct JsonEmitter {
4242
pretty: bool,
4343
ui_testing: bool,
4444
json_rendered: HumanReadableErrorType,
45-
terminal_width: Option<usize>,
45+
output_width: Option<usize>,
4646
macro_backtrace: bool,
4747
}
4848

@@ -54,7 +54,7 @@ impl JsonEmitter {
5454
fallback_bundle: LazyFallbackBundle,
5555
pretty: bool,
5656
json_rendered: HumanReadableErrorType,
57-
terminal_width: Option<usize>,
57+
output_width: Option<usize>,
5858
macro_backtrace: bool,
5959
) -> JsonEmitter {
6060
JsonEmitter {
@@ -66,7 +66,7 @@ impl JsonEmitter {
6666
pretty,
6767
ui_testing: false,
6868
json_rendered,
69-
terminal_width,
69+
output_width,
7070
macro_backtrace,
7171
}
7272
}
@@ -76,7 +76,7 @@ impl JsonEmitter {
7676
json_rendered: HumanReadableErrorType,
7777
fluent_bundle: Option<Lrc<FluentBundle>>,
7878
fallback_bundle: LazyFallbackBundle,
79-
terminal_width: Option<usize>,
79+
output_width: Option<usize>,
8080
macro_backtrace: bool,
8181
) -> JsonEmitter {
8282
let file_path_mapping = FilePathMapping::empty();
@@ -87,7 +87,7 @@ impl JsonEmitter {
8787
fallback_bundle,
8888
pretty,
8989
json_rendered,
90-
terminal_width,
90+
output_width,
9191
macro_backtrace,
9292
)
9393
}
@@ -100,7 +100,7 @@ impl JsonEmitter {
100100
fallback_bundle: LazyFallbackBundle,
101101
pretty: bool,
102102
json_rendered: HumanReadableErrorType,
103-
terminal_width: Option<usize>,
103+
output_width: Option<usize>,
104104
macro_backtrace: bool,
105105
) -> JsonEmitter {
106106
JsonEmitter {
@@ -112,7 +112,7 @@ impl JsonEmitter {
112112
pretty,
113113
ui_testing: false,
114114
json_rendered,
115-
terminal_width,
115+
output_width,
116116
macro_backtrace,
117117
}
118118
}
@@ -345,7 +345,7 @@ impl Diagnostic {
345345
je.fluent_bundle.clone(),
346346
je.fallback_bundle.clone(),
347347
false,
348-
je.terminal_width,
348+
je.output_width,
349349
je.macro_backtrace,
350350
)
351351
.ui_testing(je.ui_testing)

Diff for: compiler/rustc_session/src/config.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ impl Default for Options {
726726
prints: Vec::new(),
727727
cg: Default::default(),
728728
error_format: ErrorOutputType::default(),
729-
terminal_width: None,
729+
output_width: None,
730730
externs: Externs(BTreeMap::new()),
731731
crate_name: None,
732732
libs: Vec::new(),
@@ -1430,8 +1430,8 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
14301430
),
14311431
opt::opt_s(
14321432
"",
1433-
"terminal-width",
1434-
"Inform rustc of the width of the terminal so that errors can be truncated",
1433+
"output-width",
1434+
"Inform rustc of the width of the output so that errors can be truncated to fit",
14351435
"WIDTH",
14361436
),
14371437
opt::multi_s(
@@ -2209,8 +2209,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
22092209

22102210
let error_format = parse_error_format(matches, color, json_rendered);
22112211

2212-
let terminal_width = matches.opt_get("terminal-width").unwrap_or_else(|_| {
2213-
early_error(error_format, "`--terminal-width` must be an positive integer");
2212+
let output_width = matches.opt_get("output-width").unwrap_or_else(|_| {
2213+
early_error(error_format, "`--output-width` must be an positive integer");
22142214
});
22152215

22162216
let unparsed_crate_types = matches.opt_strs("crate-type");
@@ -2485,7 +2485,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
24852485
prints,
24862486
cg,
24872487
error_format,
2488-
terminal_width,
2488+
output_width,
24892489
externs,
24902490
unstable_features: UnstableFeatures::from_environment(crate_name.as_deref()),
24912491
crate_name,

Diff for: compiler/rustc_session/src/options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ top_level_options!(
170170

171171
test: bool [TRACKED],
172172
error_format: ErrorOutputType [UNTRACKED],
173-
terminal_width: Option<usize> [UNTRACKED],
173+
output_width: Option<usize> [UNTRACKED],
174174

175175
/// If `Some`, enable incremental compilation, using the given
176176
/// directory to store intermediate results.
@@ -1389,6 +1389,8 @@ options! {
13891389
"panic strategy for out-of-memory handling"),
13901390
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
13911391
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
1392+
output_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1393+
"set the current output width for diagnostic truncation"),
13921394
panic_abort_tests: bool = (false, parse_bool, [TRACKED],
13931395
"support compiling tests with panic=abort (default: no)"),
13941396
panic_in_drop: PanicStrategy = (PanicStrategy::Unwind, parse_panic_strategy, [TRACKED],
@@ -1515,8 +1517,6 @@ options! {
15151517
"show extended diagnostic help (default: no)"),
15161518
temps_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
15171519
"the directory the intermediate files are written to"),
1518-
terminal_width: Option<usize> = (None, parse_opt_number, [UNTRACKED],
1519-
"set the current terminal width"),
15201520
// Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved
15211521
// alongside query results and changes to translation options can affect diagnostics - so
15221522
// translation options should be tracked.

Diff for: compiler/rustc_session/src/session.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ fn default_emitter(
11621162
fallback_bundle,
11631163
short,
11641164
sopts.debugging_opts.teach,
1165-
sopts.terminal_width,
1165+
sopts.output_width,
11661166
macro_backtrace,
11671167
),
11681168
Some(dst) => EmitterWriter::new(
@@ -1188,7 +1188,7 @@ fn default_emitter(
11881188
fallback_bundle,
11891189
pretty,
11901190
json_rendered,
1191-
sopts.terminal_width,
1191+
sopts.output_width,
11921192
macro_backtrace,
11931193
)
11941194
.ui_testing(sopts.debugging_opts.ui_testing),
@@ -1202,7 +1202,7 @@ fn default_emitter(
12021202
fallback_bundle,
12031203
pretty,
12041204
json_rendered,
1205-
sopts.terminal_width,
1205+
sopts.output_width,
12061206
macro_backtrace,
12071207
)
12081208
.ui_testing(sopts.debugging_opts.ui_testing),

Diff for: src/librustdoc/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(crate) struct Options {
7474
/// How to format errors and warnings.
7575
pub(crate) error_format: ErrorOutputType,
7676
/// Width of terminal to truncate errors appropriately.
77-
pub(crate) terminal_width: Option<usize>,
77+
pub(crate) output_width: Option<usize>,
7878
/// Library search paths to hand to the compiler.
7979
pub(crate) libs: Vec<SearchPath>,
8080
/// Library search paths strings to hand to the compiler.
@@ -336,12 +336,12 @@ impl Options {
336336
let config::JsonConfig { json_rendered, json_unused_externs, .. } =
337337
config::parse_json(matches);
338338
let error_format = config::parse_error_format(matches, color, json_rendered);
339-
let terminal_width = matches.opt_get("terminal-width").unwrap_or_default();
339+
let output_width = matches.opt_get("output-width").unwrap_or_default();
340340

341341
let codegen_options = CodegenOptions::build(matches, error_format);
342342
let debugging_opts = DebuggingOptions::build(matches, error_format);
343343

344-
let diag = new_handler(error_format, None, terminal_width, &debugging_opts);
344+
let diag = new_handler(error_format, None, output_width, &debugging_opts);
345345

346346
// check for deprecated options
347347
check_deprecated_options(matches, &diag);
@@ -705,7 +705,7 @@ impl Options {
705705
input,
706706
proc_macro_crate,
707707
error_format,
708-
terminal_width,
708+
output_width,
709709
libs,
710710
lib_strs,
711711
externs,

Diff for: src/librustdoc/core.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'tcx> DocContext<'tcx> {
154154
pub(crate) fn new_handler(
155155
error_format: ErrorOutputType,
156156
source_map: Option<Lrc<source_map::SourceMap>>,
157-
terminal_width: Option<usize>,
157+
output_width: Option<usize>,
158158
debugging_opts: &DebuggingOptions,
159159
) -> rustc_errors::Handler {
160160
let fallback_bundle =
@@ -170,7 +170,7 @@ pub(crate) fn new_handler(
170170
fallback_bundle,
171171
short,
172172
debugging_opts.teach,
173-
terminal_width,
173+
output_width,
174174
false,
175175
)
176176
.ui_testing(debugging_opts.ui_testing),
@@ -188,7 +188,7 @@ pub(crate) fn new_handler(
188188
fallback_bundle,
189189
pretty,
190190
json_rendered,
191-
terminal_width,
191+
output_width,
192192
false,
193193
)
194194
.ui_testing(debugging_opts.ui_testing),
@@ -209,7 +209,7 @@ pub(crate) fn create_config(
209209
crate_name,
210210
proc_macro_crate,
211211
error_format,
212-
terminal_width,
212+
output_width,
213213
libs,
214214
externs,
215215
mut cfgs,
@@ -268,7 +268,7 @@ pub(crate) fn create_config(
268268
actually_rustdoc: true,
269269
debugging_opts,
270270
error_format,
271-
terminal_width,
271+
output_width,
272272
edition,
273273
describe_lints,
274274
crate_name,

Diff for: src/librustdoc/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,11 @@ fn opts() -> Vec<RustcOptGroup> {
462462
"human|json|short",
463463
)
464464
}),
465-
unstable("terminal-width", |o| {
465+
unstable("output-width", |o| {
466466
o.optopt(
467467
"",
468-
"terminal-width",
469-
"Provide width of the terminal for truncated error messages",
468+
"output-width",
469+
"Provide width of the output for truncated error messages",
470470
"WIDTH",
471471
)
472472
}),
@@ -744,7 +744,7 @@ fn main_options(options: config::Options) -> MainResult {
744744
let diag = core::new_handler(
745745
options.error_format,
746746
None,
747-
options.terminal_width,
747+
options.output_width,
748748
&options.debugging_opts,
749749
);
750750

Diff for: src/test/run-make/issue-88756-default-output/output-default.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ Options:
110110
never = never colorize output
111111
--error-format human|json|short
112112
How errors and other messages are produced
113-
--terminal-width WIDTH
114-
Provide width of the terminal for truncated error
113+
--output-width WIDTH
114+
Provide width of the output for truncated error
115115
messages
116116
--json CONFIG Configure the structure of JSON diagnostics
117117
--disable-minification

Diff for: src/test/rustdoc-ui/terminal-width.rs renamed to src/test/rustdoc-ui/output-width.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Zunstable-options --terminal-width=10
1+
// compile-flags: -Zunstable-options --output-width=10
22
#![deny(rustdoc::bare_urls)]
33

44
/// This is a long line that contains a http://link.com

Diff for: src/test/rustdoc-ui/terminal-width.stderr renamed to src/test/rustdoc-ui/output-width.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: this URL is not a hyperlink
2-
--> $DIR/terminal-width.rs:4:41
2+
--> $DIR/output-width.rs:4:41
33
|
44
LL | ... a http://link.com
55
| ^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://link.com>`
66
|
77
note: the lint level is defined here
8-
--> $DIR/terminal-width.rs:2:9
8+
--> $DIR/output-width.rs:2:9
99
|
1010
LL | ...ny(rustdoc::bare_url...
1111
| ^^^^^^^^^^^^^^^^^^

Diff for: src/test/ui/output-width/flag-human.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-flags: --output-width=20
2+
3+
// This test checks that `-Z output-width` effects the human error output by restricting it to an
4+
// arbitrarily low value so that the effect is visible.
5+
6+
fn main() {
7+
let _: () = 42;
8+
//~^ ERROR mismatched types
9+
}

Diff for: src/test/ui/output-width/flag-json.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-flags: --output-width=20 --error-format=json
2+
3+
// This test checks that `-Z output-width` effects the JSON error output by restricting it to an
4+
// arbitrarily low value so that the effect is visible.
5+
6+
fn main() {
7+
let _: () = 42;
8+
//~^ ERROR arguments to this function are incorrect
9+
}

Diff for: src/test/ui/terminal-width/flag-json.stderr renamed to src/test/ui/output-width/flag-json.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This error occurs when an expression was used in a place where the compiler
2424
expected an expression of a different type. It can occur in several cases, the
2525
most common being when calling a function and passing an argument which has a
2626
different type than the matching type in the function declaration.
27-
"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":243,"byte_end":245,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":238,"byte_end":240,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
27+
"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":239,"byte_end":241,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":234,"byte_end":236,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
2828
--> $DIR/flag-json.rs:7:17
2929
|
3030
LL | ..._: () = 42;

0 commit comments

Comments
 (0)