diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 904d6f8cfd808..84d9b1b9ea298 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -934,7 +934,7 @@ fn describe_codegen_flags() { print_flag_list("-C", config::CG_OPTIONS); } -fn print_flag_list( +pub fn print_flag_list( cmdline_opt: &str, flag_list: &[(&'static str, T, &'static str, &'static str)], ) { diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 1ff2c8191e562..c17f333f3ac92 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -6,6 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; use rustc_data_structures::fx::FxHashMap; +use rustc_driver::print_flag_list; use rustc_session::config::{ self, parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType, }; @@ -310,11 +311,12 @@ impl RenderOptions { impl Options { /// Parses the given command-line for options. If an error message or other early-return has /// been printed, returns `Err` with the exit code. - crate fn from_matches(matches: &getopts::Matches) -> Result { + crate fn from_matches(matches: &getopts::Matches, args: Vec) -> Result { + let args = &args[1..]; // Check for unstable options. nightly_options::check_nightly_options(matches, &opts()); - if matches.opt_present("h") || matches.opt_present("help") { + if args.is_empty() || matches.opt_present("h") || matches.opt_present("help") { crate::usage("rustdoc"); return Err(0); } else if matches.opt_present("version") { @@ -335,6 +337,21 @@ impl Options { // check for deprecated options check_deprecated_options(matches, &diag); + let z_flags = matches.opt_strs("Z"); + if z_flags.iter().any(|x| *x == "help") { + print_flag_list("-Z", config::DB_OPTIONS); + return Err(0); + } + let c_flags = matches.opt_strs("C"); + if c_flags.iter().any(|x| *x == "help") { + print_flag_list("-C", config::CG_OPTIONS); + return Err(0); + } + let w_flags = matches.opt_strs("W"); + if w_flags.iter().any(|x| *x == "help") { + print_flag_list("-W", config::DB_OPTIONS); + return Err(0); + } if matches.opt_strs("passes") == ["list"] { println!("Available passes for running rustdoc:"); for pass in passes::PASSES { @@ -415,6 +432,7 @@ impl Options { } return Err(0); } + let (_lint_opts, _describe_lints, _lint_cap) = get_cmd_lint_options(matches, error_format); if matches.free.is_empty() { diag.struct_err("missing file operand").emit(); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index cd196a0184799..2091871a32ab6 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -691,7 +691,7 @@ fn main_args(at_args: &[String]) -> MainResult { // Note that we discard any distinction between different non-zero exit // codes from `from_matches` here. - let options = match config::Options::from_matches(&matches) { + let options = match config::Options::from_matches(&matches, args) { Ok(opts) => opts, Err(code) => { return if code == 0 { diff --git a/src/test/run-make/issue-88756-default-output/Makefile b/src/test/run-make/issue-88756-default-output/Makefile new file mode 100644 index 0000000000000..88f18c67087d7 --- /dev/null +++ b/src/test/run-make/issue-88756-default-output/Makefile @@ -0,0 +1,4 @@ +-include ../../run-make-fulldeps/tools.mk + +all: + $(BARE_RUSTDOC) 2>&1 | diff - output-default.stdout diff --git a/src/test/run-make/issue-88756-default-output/README.md b/src/test/run-make/issue-88756-default-output/README.md new file mode 100644 index 0000000000000..8cbfac4f7d2f1 --- /dev/null +++ b/src/test/run-make/issue-88756-default-output/README.md @@ -0,0 +1 @@ +This is a test to verify that the default behavior of `rustdoc` is printing out help output instead of erroring out (#88756). diff --git a/src/test/run-make/issue-88756-default-output/output-default.stdout b/src/test/run-make/issue-88756-default-output/output-default.stdout new file mode 100644 index 0000000000000..5c2949d0fd790 --- /dev/null +++ b/src/test/run-make/issue-88756-default-output/output-default.stdout @@ -0,0 +1,193 @@ +rustdoc [options] + +Options: + -h, --help show this help message + -V, --version print rustdoc's version + -v, --verbose use verbose output + -w, --output-format [html] + the output type to write + --output PATH Which directory to place the output. This option is + deprecated, use --out-dir instead. + -o, --out-dir PATH which directory to place the output + --crate-name NAME + specify the name of this crate + --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro] + Comma separated list of types of crates + for the compiler to emit + -L, --library-path DIR + directory to add to crate search path + --cfg pass a --cfg to rustc + --check-cfg pass a --check-cfg to rustc + --extern NAME[=PATH] + pass an --extern to rustc + --extern-html-root-url NAME=URL + base URL to use for dependencies; for example, + "std=/doc" links std::vec::Vec to + /doc/std/vec/struct.Vec.html + --extern-html-root-takes-precedence + give precedence to `--extern-html-root-url`, not + `html_root_url` + -C, --codegen OPT[=VALUE] + pass a codegen option to rustc + --document-private-items + document private items + --document-hidden-items + document items that have doc(hidden) + --test run code examples as tests + --test-args ARGS + arguments to pass to the test runner + --test-run-directory PATH + The working directory in which to run tests + --target TRIPLE target triple to document + --markdown-css FILES + CSS files to include via in a rendered Markdown + file + --html-in-header FILES + files to include inline in the section of a + rendered Markdown file or generated documentation + --html-before-content FILES + files to include inline between and the content + of a rendered Markdown file or generated documentation + --html-after-content FILES + files to include inline between the content and + of a rendered Markdown file or generated + documentation + --markdown-before-content FILES + files to include inline between and the content + of a rendered Markdown file or generated documentation + --markdown-after-content FILES + files to include inline between the content and + of a rendered Markdown file or generated + documentation + --markdown-playground-url URL + URL to send code snippets to + --markdown-no-toc + don't include table of contents + -e, --extend-css PATH + To add some CSS rules with a given file to generate + doc with your own theme. However, your theme might + break if the rustdoc's generated HTML changes, so be + careful! + -Z FLAG internal and debugging options (only on nightly build) + --sysroot PATH Override the system root + --playground-url URL + URL to send code snippets to, may be reset by + --markdown-playground-url or + `#![doc(html_playground_url=...)]` + --display-doctest-warnings + show warnings that originate in doctests + --crate-version VERSION + crate version to print into documentation + --sort-modules-by-appearance + sort modules by where they appear in the program, + rather than alphabetically + --default-theme THEME + Set the default theme. THEME should be the theme name, + generally lowercase. If an unknown default theme is + specified, the builtin default is used. The set of + themes, and the rustdoc built-in default, are not + stable. + --default-setting SETTING[=VALUE] + Default value for a rustdoc setting (used when + "rustdoc-SETTING" is absent from web browser Local + Storage). If VALUE is not supplied, "true" is used. + Supported SETTINGs and VALUEs are not documented and + not stable. + --theme FILES additional themes which will be added to the generated + docs + --check-theme FILES + check if given theme is valid + --resource-suffix PATH + suffix to add to CSS and JavaScript files, e.g., + "light.css" will become "light-suffix.css" + --edition EDITION + edition to use when compiling rust code (default: + 2015) + --color auto|always|never + Configure coloring of output: + auto = colorize, if output goes to a tty (default); + always = always colorize output; + never = never colorize output + --error-format human|json|short + How errors and other messages are produced + --json CONFIG Configure the structure of JSON diagnostics + --disable-minification + Disable minification applied on JS files + -A, --allow LINT Set lint allowed + -W, --warn LINT Set lint warnings + --force-warn LINT + Set lint force-warn + -D, --deny LINT Set lint denied + -F, --forbid LINT Set lint forbidden + --cap-lints LEVEL + Set the most restrictive lint level. More restrictive + lints are capped at this level. By default, it is at + `forbid` level. + --index-page PATH + Markdown file to be used as index page + --enable-index-page + To enable generation of the index page + --static-root-path PATH + Path string to force loading static files from in + output pages. If not set, uses combinations of '../' + to reach the documentation root. + --disable-per-crate-search + disables generating the crate selector on the search + box + --persist-doctests PATH + Directory to persist doctest executables into + --show-coverage + calculate percentage of public items with + documentation + --enable-per-target-ignores + parse ignore-foo for ignoring doctests on a per-target + basis + --runtool The tool to run tests with when building for a different target than host + + --runtool-arg One (of possibly many) arguments to pass to the runtool + + --test-builder PATH + The rustc-like binary to use as the test builder + --check Run rustdoc checks + --generate-redirect-map + Generate JSON file at the top level instead of + generating HTML redirection files + --emit [unversioned-shared-resources,toolchain-shared-resources,invocation-specific] + Comma separated list of types of output for rustdoc to + emit + --no-run Compile doctests without running them + --show-type-layout + Include the memory layout of types in the docs + --nocapture Don't capture stdout and stderr of tests + --generate-link-to-definition + Make the identifiers in the HTML source code pages + navigable + --scrape-examples-output-path collect function call information and output at the given path + + --scrape-examples-target-crate collect function call information for functions from the target crate + + --scrape-tests Include test code when scraping examples + --with-examples path to function call information (for displaying examples in the documentation) + + --plugin-path DIR + removed, see issue #44136 + for + more information + --passes PASSES removed, see issue #44136 + for + more information + --plugins PLUGINS + removed, see issue #44136 + for + more information + --no-defaults removed, see issue #44136 + for + more information + -r, --input-format [rust] + removed, see issue #44136 + for + more information + + @path Read newline separated options from `path` + +More information available at https://doc.rust-lang.org/nightly/rustdoc/what-is-rustdoc.html diff --git a/src/test/run-make/issue-88756-default-output/x.rs b/src/test/run-make/issue-88756-default-output/x.rs new file mode 100644 index 0000000000000..5df7576133a68 --- /dev/null +++ b/src/test/run-make/issue-88756-default-output/x.rs @@ -0,0 +1 @@ +// nothing to see here diff --git a/src/test/run-make/issue-88756-opt-help/Makefile b/src/test/run-make/issue-88756-opt-help/Makefile new file mode 100644 index 0000000000000..8ababbf5b4ebd --- /dev/null +++ b/src/test/run-make/issue-88756-opt-help/Makefile @@ -0,0 +1,4 @@ +-include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTDOC) -W help 2>&1 | diff - output-default.stdout diff --git a/src/test/run-make/issue-88756-opt-help/README.md b/src/test/run-make/issue-88756-opt-help/README.md new file mode 100644 index 0000000000000..9b742753f25b6 --- /dev/null +++ b/src/test/run-make/issue-88756-opt-help/README.md @@ -0,0 +1 @@ +This is a test to verify that `rustdoc` behaves the same as rustc and prints out help output for its options like -W (#88756). diff --git a/src/test/run-make/issue-88756-opt-help/output-default.stdout b/src/test/run-make/issue-88756-opt-help/output-default.stdout new file mode 100644 index 0000000000000..89153a7645107 --- /dev/null +++ b/src/test/run-make/issue-88756-opt-help/output-default.stdout @@ -0,0 +1,189 @@ + -W allow-features=val -- only allow the listed language features to be enabled in code (space separated) + -W always-encode-mir=val -- encode MIR of all functions into the crate metadata (default: no) + -W assume-incomplete-release=val -- make cfg(version) treat the current version as incomplete (default: no) + -W asm-comments=val -- generate comments into the assembly (may change behavior) (default: no) + -W assert-incr-state=val -- assert that the incremental cache is in given state: either `loaded` or `not-loaded`. + -W ast-json=val -- print the AST as JSON and halt (default: no) + -W ast-json-noexpand=val -- print the pre-expansion AST as JSON and halt (default: no) + -W binary-dep-depinfo=val -- include artifacts (sysroot, crate dependencies) used during compilation in dep-info (default: no) + -W borrowck=val -- select which borrowck is used (`mir` or `migrate`) (default: `migrate`) + -W branch-protection=val -- set options for branch target identification and pointer authentication on AArch64 + -W cf-protection=val -- instrument control-flow architecture protection + -W cgu-partitioning-strategy=val -- the codegen unit partitioning strategy to use + -W chalk=val -- enable the experimental Chalk-based trait solving engine + -W codegen-backend=val -- the backend to use + -W combine-cgu=val -- combine CGUs into a single one + -W crate-attr=val -- inject the given attribute in the crate + -W debug-info-for-profiling=val -- emit discriminators and other data necessary for AutoFDO + -W debug-macros=val -- emit line numbers debug info inside macros (default: no) + -W deduplicate-diagnostics=val -- deduplicate identical diagnostics (default: yes) + -W dep-info-omit-d-target=val -- in dep-info output, omit targets for tracking dependencies of the dep-info files themselves (default: no) + -W dep-tasks=val -- print tasks that execute and the color their dep node gets (requires debug build) (default: no) + -W dlltool=val -- import library generation tool (windows-gnu only) + -W dont-buffer-diagnostics=val -- emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) (default: no) + -W drop-tracking=val -- enables drop tracking in generators (default: no) + -W dual-proc-macros=val -- load proc macros for both target and host, but only link to the target (default: no) + -W dump-dep-graph=val -- dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) (default: no) + -W dump-mir=val -- dump MIR state to file. + `val` is used to select which passes and functions to dump. For example: + `all` matches all passes and functions, + `foo` matches all passes for functions whose name contains 'foo', + `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo', + `foo | bar` all passes for function names containing 'foo' or 'bar'. + -W dump-mir-dataflow=val -- in addition to `.mir` files, create graphviz `.dot` files with dataflow results (default: no) + -W dump-mir-dir=val -- the directory the MIR is dumped into (default: `mir_dump`) + -W dump-mir-exclude-pass-number=val -- exclude the pass number when dumping MIR (used in tests) (default: no) + -W dump-mir-graphviz=val -- in addition to `.mir` files, create graphviz `.dot` files (and with `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived coverage graph) (default: no) + -W dump-mir-spanview=val -- in addition to `.mir` files, create `.html` files to view spans for all `statement`s (including terminators), only `terminator` spans, or computed `block` spans (one span encompassing a block's terminator and all statements). If `-Z instrument-coverage` is also enabled, create an additional `.html` file showing the computed coverage spans. + -W emit-stack-sizes=val -- emit a section containing stack size metadata (default: no) + -W fewer-names=val -- reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) (default: no) + -W force-unstable-if-unmarked=val -- force all crates to be `rustc_private` unstable (default: no) + -W fuel=val -- set the optimization fuel quota for a crate + -W function-sections=val -- whether each function should go in its own section + -W future-incompat-test=val -- forces all lints to be future incompatible, used for internal testing (default: no) + -W gcc-ld=val -- implementation of ld used by cc + -W graphviz-dark-mode=val -- use dark-themed colors in graphviz output (default: no) + -W graphviz-font=val -- use the given `fontname` in graphviz output; can be overridden by setting environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`) + -W hir-stats=val -- print some statistics about AST and HIR (default: no) + -W human-readable-cgu-names=val -- generate human-readable, predictable names for codegen units (default: no) + -W identify-regions=val -- display unnamed regions as `'`, using a non-ident unique id (default: no) + -W incremental-ignore-spans=val -- ignore spans during ICH computation -- used for testing (default: no) + -W incremental-info=val -- print high-level information about incremental reuse (or the lack thereof) (default: no) + -W incremental-relative-spans=val -- hash spans relative to their parent item for incr. comp. (default: no) + -W incremental-verify-ich=val -- verify incr. comp. hashes of green query instances (default: no) + -W inline-mir=val -- enable MIR inlining (default: no) + -W inline-mir-threshold=val -- a default MIR inlining threshold (default: 50) + -W inline-mir-hint-threshold=val -- inlining threshold for functions with inline hint (default: 100) + -W inline-in-all-cgus=val -- control whether `#[inline]` functions are in all CGUs + -W input-stats=val -- gather statistics about the input (default: no) + -W 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: + `=all` (implicit value) + `=except-unused-generics` + `=except-unused-functions` + `=off` (default) + -W instrument-mcount=val -- insert function instrument code for mcount-based tracing (default: no) + -W keep-hygiene-data=val -- keep hygiene data after analysis (default: no) + -W link-native-libraries=val -- link native libraries in the linker invocation (default: yes) + -W link-only=val -- link the `.rlink` file generated by `-Z no-link` (default: no) + -W llvm-plugins=val -- a list LLVM plugins to enable (space separated) + -W llvm-time-trace=val -- generate JSON tracing data file from LLVM data (default: no) + -W location-detail=val -- comma separated list of location details to be tracked when using caller_location valid options are `file`, `line`, and `column` (default: all) + -W ls=val -- list the symbols defined by a library crate (default: no) + -W macro-backtrace=val -- show macro backtraces (default: no) + -W merge-functions=val -- control the operation of the MergeFunctions LLVM pass, taking the same values as the target option of the same name + -W meta-stats=val -- gather metadata statistics (default: no) + -W mir-emit-retag=val -- emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 (default: no) + -W mir-enable-passes=val -- use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be enabled, overriding all other checks. Passes that are not specified are enabled or disabled by other flags as usual. + -W mir-opt-level=val -- MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds) + -W move-size-limit=val -- the size at which the `large_assignments` lint starts to be emitted + -W mutable-noalias=val -- emit noalias metadata for mutable references (default: yes) + -W new-llvm-pass-manager=val -- use new LLVM pass manager (default: no) + -W nll-facts=val -- dump facts from NLL analysis into side files (default: no) + -W nll-facts-dir=val -- the directory the NLL facts are dumped into (default: `nll-facts`) + -W no-analysis=val -- parse and expand the source, but run no analysis + -W no-codegen=val -- run all passes except codegen; no output + -W no-generate-arange-section=val -- omit DWARF address ranges that give faster lookups + -W no-interleave-lints=val -- execute lints separately; allows benchmarking individual lints + -W no-leak-check=val -- disable the 'leak check' for subtyping; unsound, but useful for tests + -W no-link=val -- compile without linking + -W no-parallel-llvm=val -- run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO) + -W no-unique-section-names=val -- do not use unique names for text and data sections when -Z function-sections is used + -W no-profiler-runtime=val -- prevent automatic injection of the profiler_builtins crate + -W normalize-docs=val -- normalize associated items in rustdoc when generating documentation + -W oom=val -- panic strategy for out-of-memory handling + -W osx-rpath-install-name=val -- pass `-install_name @rpath/...` to the macOS linker (default: no) + -W panic-abort-tests=val -- support compiling tests with panic=abort (default: no) + -W panic-in-drop=val -- panic strategy for panics in drops + -W parse-only=val -- parse only; do not compile, assemble, or link (default: no) + -W perf-stats=val -- print some performance-related statistics (default: no) + -W pick-stable-methods-before-any-unstable=val -- try to pick stable methods first before picking any unstable methods (default: yes) + -W plt=val -- whether to use the PLT when calling into shared libraries; + only has effect for PIC code on systems with ELF binaries + (default: PLT is disabled if full relro is enabled) + -W polonius=val -- enable polonius-based borrow-checker (default: no) + -W polymorphize=val -- perform polymorphization analysis + -W pre-link-arg=val -- a single extra argument to prepend the linker invocation (can be used several times) + -W pre-link-args=val -- extra arguments to prepend to the linker invocation (space separated) + -W precise-enum-drop-elaboration=val -- use a more precise version of drop elaboration for matches on enums (default: yes). This results in better codegen, but has caused miscompilations on some tier 2 platforms. See #77382 and #74551. + -W print-fuel=val -- make rustc print the total optimization fuel used by a crate + -W print-llvm-passes=val -- print the LLVM optimization passes being run (default: no) + -W print-mono-items=val -- print the result of the monomorphization collection pass + -W print-type-sizes=val -- print layout information for each type encountered (default: no) + -W proc-macro-backtrace=val -- show backtraces for panics during proc-macro execution (default: no) + -W profile=val -- insert profiling code (default: no) + -W profile-closures=val -- profile size of closures + -W profile-emit=val -- file path to emit profiling data at runtime when using 'profile' (default based on relative source path) + -W profiler-runtime=val -- name of the profiler runtime crate to automatically inject (default: `profiler_builtins`) + -W profile-sample-use=val -- use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO) + -W query-dep-graph=val -- enable queries of the dependency graph for regression testing (default: no) + -W randomize-layout=val -- randomize the layout of types (default: no) + -W layout-seed=val -- seed layout randomization + -W relax-elf-relocations=val -- whether ELF relocations can be relaxed + -W relro-level=val -- choose which RELRO level to use + -W remap-cwd-prefix=val -- remap paths under the current working directory to this path prefix + -W simulate-remapped-rust-src-base=val -- simulate the effect of remap-debuginfo = true at bootstrapping by remapping path to rust's source base directory. only meant for testing purposes + -W report-delayed-bugs=val -- immediately print bugs registered with `delay_span_bug` (default: no) + -W sanitizer=val -- use a sanitizer + -W sanitizer-memory-track-origins=val -- enable origins tracking in MemorySanitizer + -W sanitizer-recover=val -- enable recovery for selected sanitizers + -W saturating-float-casts=val -- make float->int casts UB-free: numbers outside the integer type's range are clipped to the max/min integer respectively, and NaN is mapped to 0 (default: yes) + -W save-analysis=val -- write syntax and type analysis (in JSON format) information, in addition to normal output (default: no) + -W self-profile=val -- run the self profiler and output the raw event data + -W self-profile-events=val -- specify the events recorded by the self profiler; + for example: `-Z self-profile-events=default,query-keys` + all options: none, all, default, generic-activity, query-provider, query-cache-hit + query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes + -W share-generics=val -- make the current crate share its generic instantiations + -W show-span=val -- show spans for compiler debugging (expr|pat|ty) + -W span-debug=val -- forward proc_macro::Span's `Debug` impl to `Span` + -W span-free-formats=val -- exclude spans when debug-printing compiler state (default: no) + -W src-hash-algorithm=val -- hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`) + -W stack-protector=val -- control stack smash protection strategy (`rustc --print stack-protector-strategies` for details) + -W strip=val -- tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`) + -W split-dwarf-kind=val -- split dwarf variant (only if -Csplit-debuginfo is enabled and on relevant platform) + (default: `split`) + + `split`: sections which do not require relocation are written into a DWARF object (`.dwo`) + file which is ignored by the linker + `single`: sections which do not require relocation are written into object file but ignored + by the linker + -W split-dwarf-inlining=val -- provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF + -W symbol-mangling-version=val -- which mangling version to use for symbol names ('legacy' (default) or 'v0') + -W teach=val -- show extended diagnostic help (default: no) + -W temps-dir=val -- the directory the intermediate files are written to + -W terminal-width=val -- set the current terminal width + -W translate-lang=val -- language identifier for diagnostic output + -W translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) + -W translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics + -W tune-cpu=val -- select processor to schedule for (`rustc --print target-cpus` for details) + -W thinlto=val -- enable ThinLTO when possible + -W thir-unsafeck=val -- use the THIR unsafety checker (default: no) + -W threads=val -- use a thread pool with N threads + -W time=val -- measure time of rustc processes (default: no) + -W time-llvm-passes=val -- measure time of each LLVM pass (default: no) + -W time-passes=val -- measure time of each rustc pass (default: no) + -W tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) + -W trace-macros=val -- for every macro invocation, print its name and arguments (default: no) + -W trap-unreachable=val -- generate trap instructions for unreachable intrinsics (default: use target setting, usually yes) + -W treat-err-as-bug=val -- treat error number `val` that occurs as bug + -W trim-diagnostic-paths=val -- in diagnostics, use heuristics to shorten paths referring to items + -W ui-testing=val -- emit compiler diagnostics in a form suitable for UI testing (default: no) + -W uninit-const-chunk-threshold=val -- allow generating const initializers with mixed init/uninit chunks, and set the maximum number of chunks for which this is allowed (default: 16) + -W unleash-the-miri-inside-of-you=val -- take the brakes off const evaluation. NOTE: this is unsound (default: no) + -W unpretty=val -- present the input source, unstable (and less-pretty) variants; + `normal`, `identified`, + `expanded`, `expanded,identified`, + `expanded,hygiene` (with internal representations), + `ast-tree` (raw AST before expansion), + `ast-tree,expanded` (raw AST after expansion), + `hir` (the HIR), `hir,identified`, + `hir,typed` (HIR with types for each node), + `hir-tree` (dump the raw HIR), + `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR) + -W unsound-mir-opts=val -- enable unsound and buggy MIR optimizations (default: no) + -W unstable-options=val -- adds unstable command line options to rustc interface (default: no) + -W use-ctors-section=val -- use legacy .ctors section for initializers rather than .init_array + -W validate-mir=val -- validate MIR after each transformation + -W verbose=val -- in general, enable more debug printouts (default: no) + -W verify-llvm-ir=val -- verify LLVM IR (default: no) + -W wasi-exec-model=val -- whether to build a wasi command or reactor diff --git a/src/test/run-make/issue-88756-opt-help/x.rs b/src/test/run-make/issue-88756-opt-help/x.rs new file mode 100644 index 0000000000000..5df7576133a68 --- /dev/null +++ b/src/test/run-make/issue-88756-opt-help/x.rs @@ -0,0 +1 @@ +// nothing to see here diff --git a/src/test/rustdoc-ui/issue-83883-describe-lints.stdout b/src/test/rustdoc-ui/issue-83883-describe-lints.stdout index 651faf5761f18..89153a7645107 100644 --- a/src/test/rustdoc-ui/issue-83883-describe-lints.stdout +++ b/src/test/rustdoc-ui/issue-83883-describe-lints.stdout @@ -1,25 +1,189 @@ + -W allow-features=val -- only allow the listed language features to be enabled in code (space separated) + -W always-encode-mir=val -- encode MIR of all functions into the crate metadata (default: no) + -W assume-incomplete-release=val -- make cfg(version) treat the current version as incomplete (default: no) + -W asm-comments=val -- generate comments into the assembly (may change behavior) (default: no) + -W assert-incr-state=val -- assert that the incremental cache is in given state: either `loaded` or `not-loaded`. + -W ast-json=val -- print the AST as JSON and halt (default: no) + -W ast-json-noexpand=val -- print the pre-expansion AST as JSON and halt (default: no) + -W binary-dep-depinfo=val -- include artifacts (sysroot, crate dependencies) used during compilation in dep-info (default: no) + -W borrowck=val -- select which borrowck is used (`mir` or `migrate`) (default: `migrate`) + -W branch-protection=val -- set options for branch target identification and pointer authentication on AArch64 + -W cf-protection=val -- instrument control-flow architecture protection + -W cgu-partitioning-strategy=val -- the codegen unit partitioning strategy to use + -W chalk=val -- enable the experimental Chalk-based trait solving engine + -W codegen-backend=val -- the backend to use + -W combine-cgu=val -- combine CGUs into a single one + -W crate-attr=val -- inject the given attribute in the crate + -W debug-info-for-profiling=val -- emit discriminators and other data necessary for AutoFDO + -W debug-macros=val -- emit line numbers debug info inside macros (default: no) + -W deduplicate-diagnostics=val -- deduplicate identical diagnostics (default: yes) + -W dep-info-omit-d-target=val -- in dep-info output, omit targets for tracking dependencies of the dep-info files themselves (default: no) + -W dep-tasks=val -- print tasks that execute and the color their dep node gets (requires debug build) (default: no) + -W dlltool=val -- import library generation tool (windows-gnu only) + -W dont-buffer-diagnostics=val -- emit diagnostics rather than buffering (breaks NLL error downgrading, sorting) (default: no) + -W drop-tracking=val -- enables drop tracking in generators (default: no) + -W dual-proc-macros=val -- load proc macros for both target and host, but only link to the target (default: no) + -W dump-dep-graph=val -- dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv) (default: no) + -W dump-mir=val -- dump MIR state to file. + `val` is used to select which passes and functions to dump. For example: + `all` matches all passes and functions, + `foo` matches all passes for functions whose name contains 'foo', + `foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo', + `foo | bar` all passes for function names containing 'foo' or 'bar'. + -W dump-mir-dataflow=val -- in addition to `.mir` files, create graphviz `.dot` files with dataflow results (default: no) + -W dump-mir-dir=val -- the directory the MIR is dumped into (default: `mir_dump`) + -W dump-mir-exclude-pass-number=val -- exclude the pass number when dumping MIR (used in tests) (default: no) + -W dump-mir-graphviz=val -- in addition to `.mir` files, create graphviz `.dot` files (and with `-Z instrument-coverage`, also create a `.dot` file for the MIR-derived coverage graph) (default: no) + -W dump-mir-spanview=val -- in addition to `.mir` files, create `.html` files to view spans for all `statement`s (including terminators), only `terminator` spans, or computed `block` spans (one span encompassing a block's terminator and all statements). If `-Z instrument-coverage` is also enabled, create an additional `.html` file showing the computed coverage spans. + -W emit-stack-sizes=val -- emit a section containing stack size metadata (default: no) + -W fewer-names=val -- reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) (default: no) + -W force-unstable-if-unmarked=val -- force all crates to be `rustc_private` unstable (default: no) + -W fuel=val -- set the optimization fuel quota for a crate + -W function-sections=val -- whether each function should go in its own section + -W future-incompat-test=val -- forces all lints to be future incompatible, used for internal testing (default: no) + -W gcc-ld=val -- implementation of ld used by cc + -W graphviz-dark-mode=val -- use dark-themed colors in graphviz output (default: no) + -W graphviz-font=val -- use the given `fontname` in graphviz output; can be overridden by setting environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`) + -W hir-stats=val -- print some statistics about AST and HIR (default: no) + -W human-readable-cgu-names=val -- generate human-readable, predictable names for codegen units (default: no) + -W identify-regions=val -- display unnamed regions as `'`, using a non-ident unique id (default: no) + -W incremental-ignore-spans=val -- ignore spans during ICH computation -- used for testing (default: no) + -W incremental-info=val -- print high-level information about incremental reuse (or the lack thereof) (default: no) + -W incremental-relative-spans=val -- hash spans relative to their parent item for incr. comp. (default: no) + -W incremental-verify-ich=val -- verify incr. comp. hashes of green query instances (default: no) + -W inline-mir=val -- enable MIR inlining (default: no) + -W inline-mir-threshold=val -- a default MIR inlining threshold (default: 50) + -W inline-mir-hint-threshold=val -- inlining threshold for functions with inline hint (default: 100) + -W inline-in-all-cgus=val -- control whether `#[inline]` functions are in all CGUs + -W input-stats=val -- gather statistics about the input (default: no) + -W 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: + `=all` (implicit value) + `=except-unused-generics` + `=except-unused-functions` + `=off` (default) + -W instrument-mcount=val -- insert function instrument code for mcount-based tracing (default: no) + -W keep-hygiene-data=val -- keep hygiene data after analysis (default: no) + -W link-native-libraries=val -- link native libraries in the linker invocation (default: yes) + -W link-only=val -- link the `.rlink` file generated by `-Z no-link` (default: no) + -W llvm-plugins=val -- a list LLVM plugins to enable (space separated) + -W llvm-time-trace=val -- generate JSON tracing data file from LLVM data (default: no) + -W location-detail=val -- comma separated list of location details to be tracked when using caller_location valid options are `file`, `line`, and `column` (default: all) + -W ls=val -- list the symbols defined by a library crate (default: no) + -W macro-backtrace=val -- show macro backtraces (default: no) + -W merge-functions=val -- control the operation of the MergeFunctions LLVM pass, taking the same values as the target option of the same name + -W meta-stats=val -- gather metadata statistics (default: no) + -W mir-emit-retag=val -- emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 (default: no) + -W mir-enable-passes=val -- use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be enabled, overriding all other checks. Passes that are not specified are enabled or disabled by other flags as usual. + -W mir-opt-level=val -- MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds) + -W move-size-limit=val -- the size at which the `large_assignments` lint starts to be emitted + -W mutable-noalias=val -- emit noalias metadata for mutable references (default: yes) + -W new-llvm-pass-manager=val -- use new LLVM pass manager (default: no) + -W nll-facts=val -- dump facts from NLL analysis into side files (default: no) + -W nll-facts-dir=val -- the directory the NLL facts are dumped into (default: `nll-facts`) + -W no-analysis=val -- parse and expand the source, but run no analysis + -W no-codegen=val -- run all passes except codegen; no output + -W no-generate-arange-section=val -- omit DWARF address ranges that give faster lookups + -W no-interleave-lints=val -- execute lints separately; allows benchmarking individual lints + -W no-leak-check=val -- disable the 'leak check' for subtyping; unsound, but useful for tests + -W no-link=val -- compile without linking + -W no-parallel-llvm=val -- run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO) + -W no-unique-section-names=val -- do not use unique names for text and data sections when -Z function-sections is used + -W no-profiler-runtime=val -- prevent automatic injection of the profiler_builtins crate + -W normalize-docs=val -- normalize associated items in rustdoc when generating documentation + -W oom=val -- panic strategy for out-of-memory handling + -W osx-rpath-install-name=val -- pass `-install_name @rpath/...` to the macOS linker (default: no) + -W panic-abort-tests=val -- support compiling tests with panic=abort (default: no) + -W panic-in-drop=val -- panic strategy for panics in drops + -W parse-only=val -- parse only; do not compile, assemble, or link (default: no) + -W perf-stats=val -- print some performance-related statistics (default: no) + -W pick-stable-methods-before-any-unstable=val -- try to pick stable methods first before picking any unstable methods (default: yes) + -W plt=val -- whether to use the PLT when calling into shared libraries; + only has effect for PIC code on systems with ELF binaries + (default: PLT is disabled if full relro is enabled) + -W polonius=val -- enable polonius-based borrow-checker (default: no) + -W polymorphize=val -- perform polymorphization analysis + -W pre-link-arg=val -- a single extra argument to prepend the linker invocation (can be used several times) + -W pre-link-args=val -- extra arguments to prepend to the linker invocation (space separated) + -W precise-enum-drop-elaboration=val -- use a more precise version of drop elaboration for matches on enums (default: yes). This results in better codegen, but has caused miscompilations on some tier 2 platforms. See #77382 and #74551. + -W print-fuel=val -- make rustc print the total optimization fuel used by a crate + -W print-llvm-passes=val -- print the LLVM optimization passes being run (default: no) + -W print-mono-items=val -- print the result of the monomorphization collection pass + -W print-type-sizes=val -- print layout information for each type encountered (default: no) + -W proc-macro-backtrace=val -- show backtraces for panics during proc-macro execution (default: no) + -W profile=val -- insert profiling code (default: no) + -W profile-closures=val -- profile size of closures + -W profile-emit=val -- file path to emit profiling data at runtime when using 'profile' (default based on relative source path) + -W profiler-runtime=val -- name of the profiler runtime crate to automatically inject (default: `profiler_builtins`) + -W profile-sample-use=val -- use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO) + -W query-dep-graph=val -- enable queries of the dependency graph for regression testing (default: no) + -W randomize-layout=val -- randomize the layout of types (default: no) + -W layout-seed=val -- seed layout randomization + -W relax-elf-relocations=val -- whether ELF relocations can be relaxed + -W relro-level=val -- choose which RELRO level to use + -W remap-cwd-prefix=val -- remap paths under the current working directory to this path prefix + -W simulate-remapped-rust-src-base=val -- simulate the effect of remap-debuginfo = true at bootstrapping by remapping path to rust's source base directory. only meant for testing purposes + -W report-delayed-bugs=val -- immediately print bugs registered with `delay_span_bug` (default: no) + -W sanitizer=val -- use a sanitizer + -W sanitizer-memory-track-origins=val -- enable origins tracking in MemorySanitizer + -W sanitizer-recover=val -- enable recovery for selected sanitizers + -W saturating-float-casts=val -- make float->int casts UB-free: numbers outside the integer type's range are clipped to the max/min integer respectively, and NaN is mapped to 0 (default: yes) + -W save-analysis=val -- write syntax and type analysis (in JSON format) information, in addition to normal output (default: no) + -W self-profile=val -- run the self profiler and output the raw event data + -W self-profile-events=val -- specify the events recorded by the self profiler; + for example: `-Z self-profile-events=default,query-keys` + all options: none, all, default, generic-activity, query-provider, query-cache-hit + query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes + -W share-generics=val -- make the current crate share its generic instantiations + -W show-span=val -- show spans for compiler debugging (expr|pat|ty) + -W span-debug=val -- forward proc_macro::Span's `Debug` impl to `Span` + -W span-free-formats=val -- exclude spans when debug-printing compiler state (default: no) + -W src-hash-algorithm=val -- hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`) + -W stack-protector=val -- control stack smash protection strategy (`rustc --print stack-protector-strategies` for details) + -W strip=val -- tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`) + -W split-dwarf-kind=val -- split dwarf variant (only if -Csplit-debuginfo is enabled and on relevant platform) + (default: `split`) -Available lint options: - -W Warn about - -A Allow - -D Deny - -F Forbid (deny and all attempts to override) - - -Lint checks provided by rustc: - - $NAMES $LEVELS $MEANINGS - -Lint groups provided by rustc: - - $NAMES $SUB_LINTS - -Lint checks provided by plugins loaded by this crate: - - $NAMES $LEVELS $MEANINGS - -Lint groups provided by plugins loaded by this crate: - - rustdoc::all $GROUPS - - + `split`: sections which do not require relocation are written into a DWARF object (`.dwo`) + file which is ignored by the linker + `single`: sections which do not require relocation are written into object file but ignored + by the linker + -W split-dwarf-inlining=val -- provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF + -W symbol-mangling-version=val -- which mangling version to use for symbol names ('legacy' (default) or 'v0') + -W teach=val -- show extended diagnostic help (default: no) + -W temps-dir=val -- the directory the intermediate files are written to + -W terminal-width=val -- set the current terminal width + -W translate-lang=val -- language identifier for diagnostic output + -W translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation) + -W translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics + -W tune-cpu=val -- select processor to schedule for (`rustc --print target-cpus` for details) + -W thinlto=val -- enable ThinLTO when possible + -W thir-unsafeck=val -- use the THIR unsafety checker (default: no) + -W threads=val -- use a thread pool with N threads + -W time=val -- measure time of rustc processes (default: no) + -W time-llvm-passes=val -- measure time of each LLVM pass (default: no) + -W time-passes=val -- measure time of each rustc pass (default: no) + -W tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details) + -W trace-macros=val -- for every macro invocation, print its name and arguments (default: no) + -W trap-unreachable=val -- generate trap instructions for unreachable intrinsics (default: use target setting, usually yes) + -W treat-err-as-bug=val -- treat error number `val` that occurs as bug + -W trim-diagnostic-paths=val -- in diagnostics, use heuristics to shorten paths referring to items + -W ui-testing=val -- emit compiler diagnostics in a form suitable for UI testing (default: no) + -W uninit-const-chunk-threshold=val -- allow generating const initializers with mixed init/uninit chunks, and set the maximum number of chunks for which this is allowed (default: 16) + -W unleash-the-miri-inside-of-you=val -- take the brakes off const evaluation. NOTE: this is unsound (default: no) + -W unpretty=val -- present the input source, unstable (and less-pretty) variants; + `normal`, `identified`, + `expanded`, `expanded,identified`, + `expanded,hygiene` (with internal representations), + `ast-tree` (raw AST before expansion), + `ast-tree,expanded` (raw AST after expansion), + `hir` (the HIR), `hir,identified`, + `hir,typed` (HIR with types for each node), + `hir-tree` (dump the raw HIR), + `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR) + -W unsound-mir-opts=val -- enable unsound and buggy MIR optimizations (default: no) + -W unstable-options=val -- adds unstable command line options to rustc interface (default: no) + -W use-ctors-section=val -- use legacy .ctors section for initializers rather than .init_array + -W validate-mir=val -- validate MIR after each transformation + -W verbose=val -- in general, enable more debug printouts (default: no) + -W verify-llvm-ir=val -- verify LLVM IR (default: no) + -W wasi-exec-model=val -- whether to build a wasi command or reactor