Change:
I tried this code: I expected to see this happen: Rustdoc prints a list of all lints, the same way rustc does. Instead, this happened: Rustdoc ignored the flag. <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: rustdoc 1.53.0-nightly ( 2021-04-03) <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
option is parsed into , but is then ignored: It should be pretty straightforward to instead call when this flag is set. claim
Make sure you call init_lints first, or it will be missing rustdoc's own lints.
Re adding a test for this... is there any way to have check only for whether some substring appears within stderr? Else every time a lint is /removed, or its level modified, the test will need updating—which seems far too brittle to me?
I mean, personally that seems ok to me as long as you can update it with . But if you think it's a hassle you could use .

Discussion:
); } <del> fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) { </del> <ins> /// Write to stdout lint command options, together with a list of all available lints pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) { </ins> println!( " Available lint options:

crate maybe_sysroot: Option<PathBuf>, /// Lint information passed over the command-line. crate lint_opts: Vec<(String, Level)>, <del> /// Whether to ask rustc to describe the lints it knows. Practically speaking, this will not be /// used, since we abort if we have no input file, but it's included for completeness. </del> <ins> /// Whether to ask rustc to describe the lints it knows. </ins> crate describe_lints: bool, /// What level to cap lints at. crate lint_cap: Option<Level>,

use std::env; use std::process; <del> use rustc_driver::abort_on_err; </del> <ins> use rustc_driver::{abort_on_err, describe_lints}; </ins> use rustc_errors::ErrorReported; use rustc_interface::interface; use rustc_middle::ty::TyCtxt;

compiler.enter(|queries| { let sess = compiler.session(); <ins> if sess.opts.describe_lints { let (_, lint_store) = &*queries.register_plugins()?.peek(); describe_lints(sess, lint_store, true); return Ok(()); } </ins> // We need to hold on to the complete resolver, so we cause everything to be // cloned for the analysis passes to use. Suboptimal, but necessary in the // current architecture.

<ins> // compile-flags: -W help // check-pass // // ignore-tidy-linelength // // normalize-stdout-test: "( +name  default  meaningn +----  -------  -------n)?( *[[:word:]:-]+  (allow  |warn   |deny   |forbid )  [^n]+n)+" -> "    $$NAMES  $$LEVELS  $$MEANINGS" // normalize-stdout-test: " +name  sub-lintsn +----  ---------n( *[[:word:]:-]+  [^n]+n)+" -> "    $$NAMES  $$SUB_LINTS" // normalize-stdout-test: " +rustdoc::all(  (rustdoc::[[:word:]-]+, )*rustdoc::[[:word:]-]+)?" -> "    rustdoc::all  $$GROUPS$4" </ins>

<ins> Available lint options: -W <foo>           Warn about <foo> -A <foo>           Allow <foo> -D <foo>           Deny <foo> -F <foo>           Forbid <foo> (deny <foo> 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 </ins>