Skip to content

Commit a9e6190

Browse files
committed
Simplify determination of whether --test was passed
1 parent f921d2e commit a9e6190

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 {
@@ -146,7 +145,6 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
146145
let conf_path = clippy_config::lookup_conf_file();
147146
let previous = config.register_lints.take();
148147
let clippy_args_var = self.clippy_args_var.take();
149-
let testing = self.testing;
150148
config.psess_created = Some(Box::new(move |psess| {
151149
track_clippy_args(psess, clippy_args_var.as_deref());
152150
track_files(psess);
@@ -166,7 +164,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
166164
}
167165

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

172170
let mut list_builder = LintListBuilder::default();
@@ -193,8 +191,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
193191
}
194192
}
195193

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() {
198196
return FxHashSet::default();
199197
}
200198
let disabled = conf
@@ -386,13 +384,7 @@ pub fn main() {
386384
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
387385
if clippy_enabled {
388386
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 });
396388
} else {
397389
rustc_driver::run_compiler(&args, &mut RustcCallbacks { clippy_args_var });
398390
}

0 commit comments

Comments
 (0)