Skip to content

Commit 9268a8b

Browse files
committed
Make --print KIND=PATH unstable
rust-lang#113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable.
1 parent 23405bb commit 9268a8b

File tree

8 files changed

+34
-8
lines changed

8 files changed

+34
-8
lines changed

compiler/rustc_session/src/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,12 @@ fn collect_print_requests(
21512151
prints.extend(matches.opt_strs("print").into_iter().map(|req| {
21522152
let (req, out) = split_out_file_name(&req);
21532153

2154+
if out.is_some() && !unstable_opts.unstable_options {
2155+
handler.early_error(
2156+
"the `-Z unstable-options` flag must also be passed to \
2157+
enable the path print option",
2158+
);
2159+
}
21542160
let kind = match PRINT_KINDS.iter().find(|&&(name, _)| name == req) {
21552161
Some((_, PrintKind::TargetSpec)) => {
21562162
if unstable_opts.unstable_options {

src/doc/rustc/src/command-line-arguments.md

-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,6 @@ The valid types of print values are:
260260
This returns rustc's minimum supported deployment target if no `*_DEPLOYMENT_TARGET` variable
261261
is present in the environment, or otherwise returns the variable's parsed value.
262262

263-
A filepath may optionally be specified for each requested information kind, in
264-
the format `--print KIND=PATH`, just like for `--emit`. When a path is
265-
specified, information will be written there instead of to stdout.
266-
267263
[conditional compilation]: ../reference/conditional-compilation.html
268264
[deployment target]: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html
269265

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `--print` Options
2+
3+
The behavior of the `--print` flag can be modified by optionally be specifiying a filepath
4+
for each requested information kind, in the format `--print KIND=PATH`, just like for
5+
`--emit`. When a path is specified, information will be written there instead of to stdout.
6+
7+
This is unstable feature, so you have to provide `-Zunstable-options` to enable it.
8+
9+
## Examples
10+
11+
`rustc main.rs -Z unstable-options --print cfg=cfgs.txt`

tests/run-make/print-cfg/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ all: default output_to_file
1313

1414
output_to_file:
1515
# Backend-independent, printed by rustc_driver_impl/src/lib.rs
16-
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt
16+
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt -Z unstable-options
1717
$(CGREP) windows < $(TMPDIR)/cfg.txt
1818

1919
# Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
20-
$(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt
20+
$(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt -Z unstable-options
2121
$(CGREP) dynamic-no-pic < $(TMPDIR)/relocation-models.txt
2222

2323
# Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
24-
$(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt
24+
$(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt -Z unstable-options
2525
$(CGREP) reference-types < $(TMPDIR)/target-features.txt
2626

2727
# Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp
28-
$(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt
28+
$(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt -Z unstable-options
2929
$(CGREP) generic < $(TMPDIR)/target-cpus.txt
3030

3131
ifdef IS_WINDOWS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `-Z unstable-options` flag must also be passed to enable the path print option
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// check-fail
2+
// revisions: cfg target-features target-cpus
3+
// [cfg]compile-flags: --print cfg=cfg.txt
4+
// [target-cpus]compile-flags: --print target-cpu=target_cpu.txt
5+
// [target-features]compile-flags: --print target-features=target_features.txt
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `-Z unstable-options` flag must also be passed to enable the path print option
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: the `-Z unstable-options` flag must also be passed to enable the path print option
2+

0 commit comments

Comments
 (0)