Skip to content

Commit d1952e8

Browse files
committed
Simplify determination of whether --test was passed
1 parent e27511b commit d1952e8

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/driver.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ impl rustc_driver::Callbacks for RustcCallbacks {
136136

137137
struct ClippyCallbacks {
138138
clippy_args_var: Option<String>,
139-
testing: bool,
140139
}
141140

142141
impl rustc_driver::Callbacks for ClippyCallbacks {
@@ -145,7 +144,6 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
145144
let conf_path = clippy_config::lookup_conf_file();
146145
let previous = config.register_lints.take();
147146
let clippy_args_var = self.clippy_args_var.take();
148-
let testing = self.testing;
149147
config.psess_created = Some(Box::new(move |psess| {
150148
track_clippy_args(psess, clippy_args_var.as_deref());
151149
track_files(psess);
@@ -165,7 +163,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
165163
}
166164

167165
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);
169167
set_post_expect_filter(sess, disabled);
170168

171169
let mut list_builder = LintListBuilder::default();
@@ -192,8 +190,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
192190
}
193191
}
194192

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() {
197195
return FxHashSet::default();
198196
}
199197
let disabled = conf
@@ -384,13 +382,7 @@ pub fn main() {
384382
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
385383
if clippy_enabled {
386384
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 });
394386
} else {
395387
rustc_driver::run_compiler(&args, &mut RustcCallbacks { clippy_args_var });
396388
}

0 commit comments

Comments
 (0)