88
99// FIXME: switch to something more ergonomic here, once available.
1010// (Currently there is no way to opt into sysroot crates without `extern crate`.)
11- extern crate rustc_data_structures;
1211extern crate rustc_driver;
1312extern crate rustc_errors;
1413extern crate rustc_interface;
@@ -26,8 +25,6 @@ use std::panic;
2625use std:: path:: { Path , PathBuf } ;
2726use std:: process:: { exit, Command } ;
2827
29- mod lintlist;
30-
3128/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
3229/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
3330fn arg_value < ' a , T : Deref < Target = str > > (
@@ -92,113 +89,6 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
9289 }
9390}
9491
95- #[ allow( clippy:: find_map, clippy:: filter_map) ]
96- fn describe_lints ( ) {
97- use lintlist:: { Level , Lint , ALL_LINTS , LINT_LEVELS } ;
98- use rustc_data_structures:: fx:: FxHashSet ;
99-
100- println ! (
101- "
102- Available lint options:
103- -W <foo> Warn about <foo>
104- -A <foo> Allow <foo>
105- -D <foo> Deny <foo>
106- -F <foo> Forbid <foo> (deny <foo> and all attempts to override)
107-
108- "
109- ) ;
110-
111- let lint_level = |lint : & Lint | {
112- LINT_LEVELS
113- . iter ( )
114- . find ( |level_mapping| level_mapping. 0 == lint. group )
115- . map ( |( _, level) | match level {
116- Level :: Allow => "allow" ,
117- Level :: Warn => "warn" ,
118- Level :: Deny => "deny" ,
119- } )
120- . unwrap ( )
121- } ;
122-
123- let mut lints: Vec < _ > = ALL_LINTS . iter ( ) . collect ( ) ;
124- // The sort doesn't case-fold but it's doubtful we care.
125- lints. sort_by_cached_key ( |x : & & Lint | ( lint_level ( x) , x. name ) ) ;
126-
127- let max_lint_name_len = lints
128- . iter ( )
129- . map ( |lint| lint. name . len ( ) )
130- . map ( |len| len + "clippy::" . len ( ) )
131- . max ( )
132- . unwrap_or ( 0 ) ;
133-
134- let padded = |x : & str | {
135- let mut s = " " . repeat ( max_lint_name_len - x. chars ( ) . count ( ) ) ;
136- s. push_str ( x) ;
137- s
138- } ;
139-
140- let scoped = |x : & str | format ! ( "clippy::{}" , x) ;
141-
142- let lint_groups: FxHashSet < _ > = lints. iter ( ) . map ( |lint| lint. group ) . collect ( ) ;
143-
144- println ! ( "Lint checks provided by clippy:\n " ) ;
145- println ! ( " {} {:7.7} meaning" , padded( "name" ) , "default" ) ;
146- println ! ( " {} {:7.7} -------" , padded( "----" ) , "-------" ) ;
147-
148- let print_lints = |lints : & [ & Lint ] | {
149- for lint in lints {
150- let name = lint. name . replace ( "_" , "-" ) ;
151- println ! (
152- " {} {:7.7} {}" ,
153- padded( & scoped( & name) ) ,
154- lint_level( lint) ,
155- lint. desc
156- ) ;
157- }
158- println ! ( "\n " ) ;
159- } ;
160-
161- print_lints ( & lints) ;
162-
163- let max_group_name_len = std:: cmp:: max (
164- "clippy::all" . len ( ) ,
165- lint_groups
166- . iter ( )
167- . map ( |group| group. len ( ) )
168- . map ( |len| len + "clippy::" . len ( ) )
169- . max ( )
170- . unwrap_or ( 0 ) ,
171- ) ;
172-
173- let padded_group = |x : & str | {
174- let mut s = " " . repeat ( max_group_name_len - x. chars ( ) . count ( ) ) ;
175- s. push_str ( x) ;
176- s
177- } ;
178-
179- println ! ( "Lint groups provided by clippy:\n " ) ;
180- println ! ( " {} sub-lints" , padded_group( "name" ) ) ;
181- println ! ( " {} ---------" , padded_group( "----" ) ) ;
182- println ! ( " {} the set of all clippy lints" , padded_group( "clippy::all" ) ) ;
183-
184- let print_lint_groups = || {
185- for group in lint_groups {
186- let name = group. to_lowercase ( ) . replace ( "_" , "-" ) ;
187- let desc = lints
188- . iter ( )
189- . filter ( |& lint| lint. group == group)
190- . map ( |lint| lint. name )
191- . map ( |name| name. replace ( "_" , "-" ) )
192- . collect :: < Vec < String > > ( )
193- . join ( ", " ) ;
194- println ! ( " {} {}" , padded_group( & scoped( & name) ) , desc) ;
195- }
196- println ! ( "\n " ) ;
197- } ;
198-
199- print_lint_groups ( ) ;
200- }
201-
20292fn display_help ( ) {
20393 println ! (
20494 "\
@@ -379,17 +269,6 @@ pub fn main() {
379269 exit ( 0 ) ;
380270 }
381271
382- let should_describe_lints = || {
383- let args: Vec < _ > = env:: args ( ) . collect ( ) ;
384- args. windows ( 2 )
385- . any ( |args| args[ 1 ] == "help" && matches ! ( args[ 0 ] . as_str( ) , "-W" | "-A" | "-D" | "-F" ) )
386- } ;
387-
388- if !wrapper_mode && should_describe_lints ( ) {
389- describe_lints ( ) ;
390- exit ( 0 ) ;
391- }
392-
393272 // this conditional check for the --sysroot flag is there so users can call
394273 // `clippy_driver` directly
395274 // without having to pass --sysroot or anything
0 commit comments