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