diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 0bd98340d06..74b9e436eb1 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -37,6 +37,7 @@ Available unstable (nightly-only) flags: -Z timings -- Display concurrency information -Z doctest-xcompile -- Compile and run doctests for non-host target using runner config -Z crate-versions -- Add crate versions to generated docs + -Z terminal-width -- Provide a terminal width to rustc for error truncation Run with 'cargo -Z [FLAG] [SUBCOMMAND]'" ); diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 658231e3541..363f0415dee 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -826,3 +826,37 @@ sysroot. If you are using rustup, this documentation can be installed with The default value is `"remote"`. The value may also take a URL for a custom location. + +### terminal-width +This feature provides a new flag, `-Z terminal-width`, which is used to pass +a terminal width to `rustc` so that error messages containing long lines +can be intelligently truncated. + +For example, passing `-Z terminal-width=20` (an arbitrarily low value) might +produce the following error: + +```text +error[E0308]: mismatched types + --> src/main.rs:2:17 + | +2 | ..._: () = 42; + | -- ^^ expected `()`, found integer + | | + | expected due to this + +error: aborting due to previous error +``` + +In contrast, without `-Z terminal-width`, the error would look as shown below: + +```text +error[E0308]: mismatched types + --> src/main.rs:2:17 + | +2 | let _: () = 42; + | -- ^^ expected `()`, found integer + | | + | expected due to this + +error: aborting due to previous error +```