about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2025-05-07 15:24:46 +0000
committerGitHub <noreply@github.com>2025-05-07 15:24:46 +0000
commit34cd9486c93fa5d046967f499755909e46569a9b (patch)
treee81da6f66b235fdceae2dc3ece18c424d1299775
parentca6281628e147ba1d664b3ddee6e3a339f627f9d (diff)
parent772ea35935c8201abaa8c21387c9eda323d9184f (diff)
downloadrust-34cd9486c93fa5d046967f499755909e46569a9b.tar.gz
rust-34cd9486c93fa5d046967f499755909e46569a9b.zip
Fix diagnostic paths printed by dogfood test (#14746)
Where you would previously see

```
error: some lint
   --> src/lib.rs:1:2
```

it will now print

```
error: some lint
   --> clippy_lints/src/lib.rs:1:2
```

Ensuring you can click the link in the terminal

A workaround for us not being in a workspace

changelog: none
-rw-r--r--tests/dogfood.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/dogfood.rs b/tests/dogfood.rs
index 16a1a415102..4ac2bd53285 100644
--- a/tests/dogfood.rs
+++ b/tests/dogfood.rs
@@ -44,8 +44,8 @@ fn dogfood() {
         "rustc_tools_util",
     ] {
         println!("linting {package}");
-        if !run_clippy_for_package(package, &["-D", "clippy::all", "-D", "clippy::pedantic"]) {
-            failed_packages.push(if package.is_empty() { "root" } else { package });
+        if !run_clippy_for_package(package) {
+            failed_packages.push(package);
         }
     }
 
@@ -57,7 +57,7 @@ fn dogfood() {
 }
 
 #[must_use]
-fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
+fn run_clippy_for_package(project: &str) -> bool {
     let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
 
     let mut command = Command::new(&*test_utils::CARGO_CLIPPY_PATH);
@@ -79,15 +79,17 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
         }
     }
 
-    command.arg("--").args(args);
+    command.arg("--");
     command.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
-    command.args(["-D", "clippy::dbg_macro"]);
-
+    command.args(["-D", "clippy::all", "-D", "clippy::pedantic", "-D", "clippy::dbg_macro"]);
     if !cfg!(feature = "internal") {
         // running a clippy built without internal lints on the clippy source
-        // that contains e.g. `allow(clippy::invalid_paths)`
+        // that contains e.g. `allow(clippy::symbol_as_str)`
         command.args(["-A", "unknown_lints"]);
     }
 
+    // Workaround for not being a workspace, add the crate's directory back to the path
+    command.args(["--remap-path-prefix", &format!("={project}")]);
+
     command.status().unwrap().success()
 }