+/// Track files that may be accessed at runtime in `file_depinfo` so that cargo will re-run clippy
+/// when any of them are modified
+fn track_files(parse_sess: &mut ParseSess, conf_path_string: Option<String>) {
+ let file_depinfo = parse_sess.file_depinfo.get_mut();
+
+ // Used by `clippy::cargo` lints and to determine the MSRV. `cargo clippy` executes `clippy-driver`
+ // with the current directory set to `CARGO_MANIFEST_DIR` so a relative path is fine
+ if Path::new("Cargo.toml").exists() {
+ file_depinfo.insert(Symbol::intern("Cargo.toml"));
+ }
+
+ // `clippy.toml`
+ if let Some(path) = conf_path_string {
+ file_depinfo.insert(Symbol::intern(&path));
+ }
+
+ // During development track the `clippy-driver` executable so that cargo will re-run clippy whenever
+ // it is rebuilt
+ if cfg!(debug_assertions)
+ && let Ok(current_exe) = env::current_exe()
+ && let Some(current_exe) = current_exe.to_str()
+ {
+ file_depinfo.insert(Symbol::intern(current_exe));
+ }
+}
+