Skip to content

Commit abbd2b0

Browse files
committed
Add cargo rustc --print unstable docs.
1 parent dda0d65 commit abbd2b0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/bin/cargo/commands/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
7575
if let Some(opt_value) = args.value_of(PRINT_ARG_NAME) {
7676
config
7777
.cli_unstable()
78-
.fail_if_stable_opt(PRINT_ARG_NAME, 8923)?;
78+
.fail_if_stable_opt(PRINT_ARG_NAME, 9357)?;
7979
ops::print(&ws, &compile_opts, opt_value)?;
8080
} else {
8181
ops::compile(&ws, &compile_opts)?;

src/doc/src/reference/unstable.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,20 @@ from the root of the workspace. It also passes the `--test-run-directory` to
12481248
package. This preserves backwards compatibility and is consistent with how
12491249
normal unittests are run.
12501250

1251+
### rustc `--print`
1252+
1253+
* Tracking Issue: [#9357](https://github.com/rust-lang/cargo/issues/9357)
1254+
1255+
`cargo rustc --print=VAL` forwards the `--print` flag to `rustc` in order to
1256+
extract information from `rustc`. This runs `rustc` with the corresponding
1257+
[`--print`](https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information)
1258+
flag, and then immediately exits without compiling. Exposing this as a cargo
1259+
flag allows cargo to inject the correct target and RUSTFLAGS based on the
1260+
current configuration.
1261+
1262+
The primary use case is to run `cargo rustc --print=cfg` to get config values
1263+
for the appropriate target and influenced by any other RUSTFLAGS.
1264+
12511265
<script>
12521266
(function() {
12531267
var fragments = {

0 commit comments

Comments
 (0)