This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +43
-4
lines changed
compiler/rustc_driver/src Expand file tree Collapse file tree 5 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -845,7 +845,8 @@ the command line flag directly.
845845 ) ;
846846}
847847
848- fn describe_lints ( sess : & Session , lint_store : & LintStore , loaded_plugins : bool ) {
848+ /// Write to stdout lint command options, together with a list of all available lints
849+ pub fn describe_lints ( sess : & Session , lint_store : & LintStore , loaded_plugins : bool ) {
849850 println ! (
850851 "
851852Available lint options:
Original file line number Diff line number Diff line change @@ -97,8 +97,7 @@ crate struct Options {
9797 crate maybe_sysroot : Option < PathBuf > ,
9898 /// Lint information passed over the command-line.
9999 crate lint_opts : Vec < ( String , Level ) > ,
100- /// Whether to ask rustc to describe the lints it knows. Practically speaking, this will not be
101- /// used, since we abort if we have no input file, but it's included for completeness.
100+ /// Whether to ask rustc to describe the lints it knows.
102101 crate describe_lints : bool ,
103102 /// What level to cap lints at.
104103 crate lint_cap : Option < Level > ,
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ use std::default::Default;
7474use std:: env;
7575use std:: process;
7676
77- use rustc_driver:: abort_on_err;
77+ use rustc_driver:: { abort_on_err, describe_lints } ;
7878use rustc_errors:: ErrorReported ;
7979use rustc_interface:: interface;
8080use rustc_middle:: ty:: TyCtxt ;
@@ -705,6 +705,12 @@ fn main_options(options: config::Options) -> MainResult {
705705 compiler. enter ( |queries| {
706706 let sess = compiler. session ( ) ;
707707
708+ if sess. opts . describe_lints {
709+ let ( _, lint_store) = & * queries. register_plugins ( ) ?. peek ( ) ;
710+ describe_lints ( sess, lint_store, true ) ;
711+ return Ok ( ( ) ) ;
712+ }
713+
708714 // We need to hold on to the complete resolver, so we cause everything to be
709715 // cloned for the analysis passes to use. Suboptimal, but necessary in the
710716 // current architecture.
Original file line number Diff line number Diff line change 1+ // compile-flags: -W help
2+ // check-pass
3+ //
4+ // ignore-tidy-linelength
5+ //
6+ // normalize-stdout-test: "( +name default meaning\n +---- ------- -------\n)?( *[[:word:]:-]+ (allow |warn |deny |forbid ) [^\n]+\n)+" -> " $$NAMES $$LEVELS $$MEANINGS"
7+ // normalize-stdout-test: " +name sub-lints\n +---- ---------\n( *[[:word:]:-]+ [^\n]+\n)+" -> " $$NAMES $$SUB_LINTS"
8+ // normalize-stdout-test: " +rustdoc::all( (rustdoc::[[:word:]-]+, )*rustdoc::[[:word:]-]+)?" -> " rustdoc::all $$GROUPS$4"
Original file line number Diff line number Diff line change 1+
2+ Available lint options:
3+ -W <foo> Warn about <foo>
4+ -A <foo> Allow <foo>
5+ -D <foo> Deny <foo>
6+ -F <foo> Forbid <foo> (deny <foo> and all attempts to override)
7+
8+
9+ Lint checks provided by rustc:
10+
11+ $NAMES $LEVELS $MEANINGS
12+
13+ Lint groups provided by rustc:
14+
15+ $NAMES $SUB_LINTS
16+
17+ Lint checks provided by plugins loaded by this crate:
18+
19+ $NAMES $LEVELS $MEANINGS
20+
21+ Lint groups provided by plugins loaded by this crate:
22+
23+ rustdoc::all $GROUPS
24+
25+
You can’t perform that action at this time.
0 commit comments