diff options
| author | Urgau <urgau@numericable.fr> | 2023-07-27 19:04:13 +0200 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2023-07-27 19:05:17 +0200 |
| commit | 9268a8b060f01ace9e925f27778d2768f4850cf8 (patch) | |
| tree | c753d018025ed3c6f0a40aed2d213c1f6a8f5353 | |
| parent | 23405bb123681399c912552fa1c09264c0d4930d (diff) | |
| download | rust-9268a8b060f01ace9e925f27778d2768f4850cf8.tar.gz rust-9268a8b060f01ace9e925f27778d2768f4850cf8.zip | |
Make `--print KIND=PATH` unstable
https://github.com/rust-lang/rust/pull/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.
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 6 | ||||
| -rw-r--r-- | src/doc/rustc/src/command-line-arguments.md | 4 | ||||
| -rw-r--r-- | src/doc/unstable-book/src/compiler-flags/path-options.md | 11 | ||||
| -rw-r--r-- | tests/run-make/print-cfg/Makefile | 8 | ||||
| -rw-r--r-- | tests/ui/feature-gates/print-with-path.cfg.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/feature-gates/print-with-path.rs | 7 | ||||
| -rw-r--r-- | tests/ui/feature-gates/print-with-path.target-cpus.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/feature-gates/print-with-path.target-features.stderr | 2 |
8 files changed, 34 insertions, 8 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 36b5c385ab1..0fadcf7899d 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2151,6 +2151,12 @@ fn collect_print_requests( prints.extend(matches.opt_strs("print").into_iter().map(|req| { let (req, out) = split_out_file_name(&req); + if out.is_some() && !unstable_opts.unstable_options { + handler.early_error( + "the `-Z unstable-options` flag must also be passed to \ + enable the path print option", + ); + } let kind = match PRINT_KINDS.iter().find(|&&(name, _)| name == req) { Some((_, PrintKind::TargetSpec)) => { if unstable_opts.unstable_options { diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 4d32897cc14..2c7c05c0c4b 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -260,10 +260,6 @@ The valid types of print values are: This returns rustc's minimum supported deployment target if no `*_DEPLOYMENT_TARGET` variable is present in the environment, or otherwise returns the variable's parsed value. -A filepath may optionally be specified for each requested information kind, in -the format `--print KIND=PATH`, just like for `--emit`. When a path is -specified, information will be written there instead of to stdout. - [conditional compilation]: ../reference/conditional-compilation.html [deployment target]: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html diff --git a/src/doc/unstable-book/src/compiler-flags/path-options.md b/src/doc/unstable-book/src/compiler-flags/path-options.md new file mode 100644 index 00000000000..0f2437020dd --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/path-options.md @@ -0,0 +1,11 @@ +# `--print` Options + +The behavior of the `--print` flag can be modified by optionally be specifiying a filepath +for each requested information kind, in the format `--print KIND=PATH`, just like for +`--emit`. When a path is specified, information will be written there instead of to stdout. + +This is unstable feature, so you have to provide `-Zunstable-options` to enable it. + +## Examples + +`rustc main.rs -Z unstable-options --print cfg=cfgs.txt` diff --git a/tests/run-make/print-cfg/Makefile b/tests/run-make/print-cfg/Makefile index 6b153e5b54e..654c303b3e2 100644 --- a/tests/run-make/print-cfg/Makefile +++ b/tests/run-make/print-cfg/Makefile @@ -13,19 +13,19 @@ all: default output_to_file output_to_file: # Backend-independent, printed by rustc_driver_impl/src/lib.rs - $(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt -Z unstable-options $(CGREP) windows < $(TMPDIR)/cfg.txt # Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs - $(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt + $(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt -Z unstable-options $(CGREP) dynamic-no-pic < $(TMPDIR)/relocation-models.txt # Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs - $(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt + $(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt -Z unstable-options $(CGREP) reference-types < $(TMPDIR)/target-features.txt # Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp - $(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt + $(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt -Z unstable-options $(CGREP) generic < $(TMPDIR)/target-cpus.txt ifdef IS_WINDOWS diff --git a/tests/ui/feature-gates/print-with-path.cfg.stderr b/tests/ui/feature-gates/print-with-path.cfg.stderr new file mode 100644 index 00000000000..a6c51baa320 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.cfg.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/feature-gates/print-with-path.rs b/tests/ui/feature-gates/print-with-path.rs new file mode 100644 index 00000000000..f929c14c218 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.rs @@ -0,0 +1,7 @@ +// check-fail +// revisions: cfg target-features target-cpus +// [cfg]compile-flags: --print cfg=cfg.txt +// [target-cpus]compile-flags: --print target-cpu=target_cpu.txt +// [target-features]compile-flags: --print target-features=target_features.txt + +fn main() {} diff --git a/tests/ui/feature-gates/print-with-path.target-cpus.stderr b/tests/ui/feature-gates/print-with-path.target-cpus.stderr new file mode 100644 index 00000000000..a6c51baa320 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.target-cpus.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + diff --git a/tests/ui/feature-gates/print-with-path.target-features.stderr b/tests/ui/feature-gates/print-with-path.target-features.stderr new file mode 100644 index 00000000000..a6c51baa320 --- /dev/null +++ b/tests/ui/feature-gates/print-with-path.target-features.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the path print option + |
