Skip to content

Commit c431e6f

Browse files
authored
Rollup merge of #99055 - GuillaumeGomez:rustdoc-help-options, r=jyn514
Fix rustdoc help options Fixes #98976. Since you're the one who found out about the problem and also provided the solution (thanks for both!): r? ```@jyn514```
2 parents 601c5a2 + b65d3a6 commit c431e6f

File tree

5 files changed

+265
-11
lines changed

5 files changed

+265
-11
lines changed

src/librustdoc/config.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,17 @@ impl Options {
329329
return Err(0);
330330
}
331331

332+
let z_flags = matches.opt_strs("Z");
333+
if z_flags.iter().any(|x| *x == "help") {
334+
print_flag_list("-Z", config::DB_OPTIONS);
335+
return Err(0);
336+
}
337+
let c_flags = matches.opt_strs("C");
338+
if c_flags.iter().any(|x| *x == "help") {
339+
print_flag_list("-C", config::CG_OPTIONS);
340+
return Err(0);
341+
}
342+
332343
let color = config::parse_color(matches);
333344
let config::JsonConfig { json_rendered, json_unused_externs, .. } =
334345
config::parse_json(matches);
@@ -343,17 +354,6 @@ impl Options {
343354
// check for deprecated options
344355
check_deprecated_options(matches, &diag);
345356

346-
let z_flags = matches.opt_strs("Z");
347-
if z_flags.iter().any(|x| *x == "help") {
348-
print_flag_list("-Z", config::DB_OPTIONS);
349-
return Err(0);
350-
}
351-
let c_flags = matches.opt_strs("C");
352-
if c_flags.iter().any(|x| *x == "help") {
353-
print_flag_list("-C", config::CG_OPTIONS);
354-
return Err(0);
355-
}
356-
357357
if matches.opt_strs("passes") == ["list"] {
358358
println!("Available passes for running rustdoc:");
359359
for pass in passes::PASSES {

src/test/rustdoc-ui/c-help.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// check-pass
2+
// compile-flags: -Chelp
3+
4+
pub struct Foo;

src/test/rustdoc-ui/c-help.stdout

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-C ar=val -- this option is deprecated and does nothing
2+
-C code-model=val -- choose the code model to use (`rustc --print code-models` for details)
3+
-C codegen-units=val -- divide crate into N units to optimize in parallel
4+
-C control-flow-guard=val -- use Windows Control Flow Guard (default: no)
5+
-C debug-assertions=val -- explicitly enable the `cfg(debug_assertions)` directive
6+
-C debuginfo=val -- debug info emission level (0 = no debug info, 1 = line tables only, 2 = full debug info with variable and type information; default: 0)
7+
-C default-linker-libraries=val -- allow the linker to link its default libraries (default: no)
8+
-C embed-bitcode=val -- emit bitcode in rlibs (default: yes)
9+
-C extra-filename=val -- extra data to put in each output filename
10+
-C force-frame-pointers=val -- force use of the frame pointers
11+
-C force-unwind-tables=val -- force use of unwind tables
12+
-C incremental=val -- enable incremental compilation
13+
-C inline-threshold=val -- set the threshold for inlining a function
14+
-C instrument-coverage=val -- instrument the generated code to support LLVM source-based code coverage reports (note, the compiler build config must include `profiler = true`); implies `-C symbol-mangling-version=v0`. Optional values are:
15+
`=all` (implicit value)
16+
`=except-unused-generics`
17+
`=except-unused-functions`
18+
`=off` (default)
19+
-C link-arg=val -- a single extra argument to append to the linker invocation (can be used several times)
20+
-C link-args=val -- extra arguments to append to the linker invocation (space separated)
21+
-C link-dead-code=val -- keep dead code at link time (useful for code coverage) (default: no)
22+
-C link-self-contained=val -- control whether to link Rust provided C objects/libraries or rely
23+
on C toolchain installed in the system
24+
-C linker=val -- system linker to link outputs with
25+
-C linker-flavor=val -- linker flavor
26+
-C linker-plugin-lto=val -- generate build artifacts that are compatible with linker-based LTO
27+
-C llvm-args=val -- a list of arguments to pass to LLVM (space separated)
28+
-C lto=val -- perform LLVM link-time optimizations
29+
-C metadata=val -- metadata to mangle symbol names with
30+
-C no-prepopulate-passes=val -- give an empty list of passes to the pass manager
31+
-C no-redzone=val -- disable the use of the redzone
32+
-C no-stack-check=val -- this option is deprecated and does nothing
33+
-C no-vectorize-loops=val -- disable loop vectorization optimization passes
34+
-C no-vectorize-slp=val -- disable LLVM's SLP vectorization pass
35+
-C opt-level=val -- optimization level (0-3, s, or z; default: 0)
36+
-C overflow-checks=val -- use overflow checks for integer arithmetic
37+
-C panic=val -- panic strategy to compile crate with
38+
-C passes=val -- a list of extra LLVM passes to run (space separated)
39+
-C prefer-dynamic=val -- prefer dynamic linking to static linking (default: no)
40+
-C profile-generate=val -- compile the program with profiling instrumentation
41+
-C profile-use=val -- use the given `.profdata` file for profile-guided optimization
42+
-C relocation-model=val -- control generation of position-independent code (PIC) (`rustc --print relocation-models` for details)
43+
-C remark=val -- print remarks for these optimization passes (space separated, or "all")
44+
-C rpath=val -- set rpath values in libs/exes (default: no)
45+
-C save-temps=val -- save all temporary output files during compilation (default: no)
46+
-C soft-float=val -- use soft float ABI (*eabihf targets only) (default: no)
47+
-C split-debuginfo=val -- how to handle split-debuginfo, a platform-specific option
48+
-C strip=val -- tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)
49+
-C symbol-mangling-version=val -- which mangling version to use for symbol names ('legacy' (default) or 'v0')
50+
-C target-cpu=val -- select target processor (`rustc --print target-cpus` for details)
51+
-C target-feature=val -- target specific attributes. (`rustc --print target-features` for details). This feature is unsafe.

src/test/rustdoc-ui/z-help.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// check-pass
2+
// compile-flags: -Zhelp
3+
4+
pub struct Foo;

0 commit comments

Comments
 (0)