about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-13 21:31:11 +0000
committerbors <bors@rust-lang.org>2023-07-13 21:31:11 +0000
commit4b355d8f31a433ba9c45c2a2f2041b3a52e93744 (patch)
treed37f50dadd6bd66ae3e579840dc61e7092877bcc
parent7ccf5d404b0e044cfd1732aa5c33b16ad2c53d48 (diff)
parent36279f1b631c345d22111809536edf70522d256e (diff)
downloadrust-4b355d8f31a433ba9c45c2a2f2041b3a52e93744.tar.gz
rust-4b355d8f31a433ba9c45c2a2f2041b3a52e93744.zip
Auto merge of #11154 - Alexendoo:track-clippy-conf-dir, r=flip1995
Trigger a rebuild when `CLIPPY_CONF_DIR` changes

changelog: none

This is a fix for https://github.com/rust-lang/rust-clippy/issues/9928#issuecomment-1634698183, any time `CLIPPY_CONF_DIR` changes cargo will now rebuild the crate clippy is being run on, giving it a chance to lint with the (potentially) different config file

r? `@flip1995`
-rw-r--r--src/driver.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/driver.rs b/src/driver.rs
index 1eb288b153a..ee17feed77a 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -130,6 +130,13 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
         config.parse_sess_created = Some(Box::new(move |parse_sess| {
             track_clippy_args(parse_sess, &clippy_args_var);
             track_files(parse_sess);
+
+            // Trigger a rebuild if CLIPPY_CONF_DIR changes. The value must be a valid string so
+            // changes between dirs that are invalid UTF-8 will not trigger rebuilds
+            parse_sess.env_depinfo.get_mut().insert((
+                Symbol::intern("CLIPPY_CONF_DIR"),
+                env::var("CLIPPY_CONF_DIR").ok().map(|dir| Symbol::intern(&dir)),
+            ));
         }));
         config.register_lints = Some(Box::new(move |sess, lint_store| {
             // technically we're ~guaranteed that this is none but might as well call anything that