@@ -136,7 +136,6 @@ impl rustc_driver::Callbacks for RustcCallbacks {
136
136
137
137
struct ClippyCallbacks {
138
138
clippy_args_var : Option < String > ,
139
- testing : bool ,
140
139
}
141
140
142
141
impl rustc_driver:: Callbacks for ClippyCallbacks {
@@ -145,7 +144,6 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
145
144
let conf_path = clippy_config:: lookup_conf_file ( ) ;
146
145
let previous = config. register_lints . take ( ) ;
147
146
let clippy_args_var = self . clippy_args_var . take ( ) ;
148
- let testing = self . testing ;
149
147
config. psess_created = Some ( Box :: new ( move |psess| {
150
148
track_clippy_args ( psess, clippy_args_var. as_deref ( ) ) ;
151
149
track_files ( psess) ;
@@ -165,7 +163,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
165
163
}
166
164
167
165
let conf = clippy_config:: Conf :: read ( sess, & conf_path) ;
168
- let disabled = build_disabled_set ( sess, conf, testing ) ;
166
+ let disabled = build_disabled_set ( sess, conf) ;
169
167
set_post_expect_filter ( sess, disabled) ;
170
168
171
169
let mut list_builder = LintListBuilder :: default ( ) ;
@@ -192,8 +190,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
192
190
}
193
191
}
194
192
195
- fn build_disabled_set ( sess : & Session , conf : & ' static Conf , testing : bool ) -> FxHashSet < & ' static str > {
196
- if !testing {
193
+ fn build_disabled_set ( sess : & Session , conf : & ' static Conf ) -> FxHashSet < & ' static str > {
194
+ if sess . is_test_crate ( ) {
197
195
return FxHashSet :: default ( ) ;
198
196
}
199
197
let disabled = conf
@@ -384,13 +382,7 @@ pub fn main() {
384
382
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
385
383
if clippy_enabled {
386
384
args. extend ( clippy_args) ;
387
- rustc_driver:: run_compiler (
388
- & args,
389
- & mut ClippyCallbacks {
390
- clippy_args_var,
391
- testing : orig_args. iter ( ) . any ( |arg| arg == "--test" ) ,
392
- } ,
393
- ) ;
385
+ rustc_driver:: run_compiler ( & args, & mut ClippyCallbacks { clippy_args_var } ) ;
394
386
} else {
395
387
rustc_driver:: run_compiler ( & args, & mut RustcCallbacks { clippy_args_var } ) ;
396
388
}
0 commit comments