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