Skip to content

Commit 4177f66

Browse files
committed
Add documentation for -Z terminal-width
This commit adds relevant documentation for the `-Z terminal-width` flag. Signed-off-by: David Wood <[email protected]>
1 parent 6d740aa commit 4177f66

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/bin/cargo/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Available unstable (nightly-only) flags:
3737
-Z timings -- Display concurrency information
3838
-Z doctest-xcompile -- Compile and run doctests for non-host target using runner config
3939
-Z crate-versions -- Add crate versions to generated docs
40+
-Z terminal-width -- Provide a terminal width to rustc for error truncation
4041
4142
Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
4243
);

src/doc/src/reference/unstable.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,37 @@ sysroot. If you are using rustup, this documentation can be installed with
826826
The default value is `"remote"`.
827827

828828
The value may also take a URL for a custom location.
829+
830+
### terminal-width
831+
This feature provides a new flag, `-Z terminal-width`, which is used to pass
832+
a terminal width to `rustc` so that error messages containing long lines
833+
can be intelligently truncated.
834+
835+
For example, passing `-Z terminal-width=20` (an arbitrarily low value) might
836+
produce the following error:
837+
838+
```text
839+
error[E0308]: mismatched types
840+
--> src/main.rs:2:17
841+
|
842+
2 | ..._: () = 42;
843+
| -- ^^ expected `()`, found integer
844+
| |
845+
| expected due to this
846+
847+
error: aborting due to previous error
848+
```
849+
850+
In contrast, without `-Z terminal-width`, the error would look as shown below:
851+
852+
```text
853+
error[E0308]: mismatched types
854+
--> src/main.rs:2:17
855+
|
856+
2 | let _: () = 42;
857+
| -- ^^ expected `()`, found integer
858+
| |
859+
| expected due to this
860+
861+
error: aborting due to previous error
862+
```

0 commit comments

Comments
 (0)