File tree 5 files changed +43
-4
lines changed
compiler/rustc_driver/src
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.
845
845
) ;
846
846
}
847
847
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 ) {
849
850
println ! (
850
851
"
851
852
Available lint options:
Original file line number Diff line number Diff line change @@ -97,8 +97,7 @@ crate struct Options {
97
97
crate maybe_sysroot : Option < PathBuf > ,
98
98
/// Lint information passed over the command-line.
99
99
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.
102
101
crate describe_lints : bool ,
103
102
/// What level to cap lints at.
104
103
crate lint_cap : Option < Level > ,
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ use std::default::Default;
74
74
use std:: env;
75
75
use std:: process;
76
76
77
- use rustc_driver:: abort_on_err;
77
+ use rustc_driver:: { abort_on_err, describe_lints } ;
78
78
use rustc_errors:: ErrorReported ;
79
79
use rustc_interface:: interface;
80
80
use rustc_middle:: ty:: TyCtxt ;
@@ -705,6 +705,12 @@ fn main_options(options: config::Options) -> MainResult {
705
705
compiler. enter ( |queries| {
706
706
let sess = compiler. session ( ) ;
707
707
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
+
708
714
// We need to hold on to the complete resolver, so we cause everything to be
709
715
// cloned for the analysis passes to use. Suboptimal, but necessary in the
710
716
// 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