Repository: rust-lang/cargo (rust)

Issue:
Inconsistent summary on error count with --message-format=json
### Problem

`cargo check` emits a good summary on error count, but with `--message-format json`, the count number is increased by 1 because it seems to include the error summary itself as a new error. This also influences summary count of clippy in the same way.

As for warning count, the former reports the count, but with json format, no count is reported.

### Steps

Repoducible repo: https://github.com/os-checker/MRE-cargo-error-count

```rust
// src/main.rs
#![deny(warnings)]
fn main() {
    let a = 1;
}
```

```rust
$ cargo check
error: could not compile `cargo-error-count` (bin "cargo-error-count") due to 1 previous error

$ cargo check --message-format json
error: could not compile `cargo-error-count` (bin "cargo-error-count") due to 2 previous errors
```

Note: this inconsistency might be a bit different on warning report

```rust
# with no #![deny(warnings)]
$ cargo check
warning: `cargo-error-count` (bin "cargo-error-count") generated 1 warning

# with no #![deny(warnings)]
$ cargo check --message-format json
# no count reported
```


### Possible Solution(s)

_No response_

### Notes

_No response_

### Version

```text
cargo 1.82.0-nightly (0d8d22f83 2024-08-08)
release: 1.82.0-nightly
commit-hash: 0d8d22f83b066503f6b2b755925197e959e58b4f
commit-date: 2024-08-08
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/3.3.1)
ssl: OpenSSL 3.3.1 4 Jun 2024
os: Ubuntu 22.4.0 (jammy) [64-bit]
```


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"yichi170"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->

Pull request:
fix: correct error count for `cargo check --message-format json`
Hi! This is my first time contributing to Cargo. If there is anything that I need to do, please let me know!
(I'm not sure whether the commit message is aligned with the Cargo's convention. If it doesn't, I'm willing to modify it!)

This PR resolves the issue with incorrect error count and ensures warnings are correctly displayed when using `cargo check --message-format json`.

Fixes #14472


Patch:
diff --git a/src/cargo/core/compiler/compilation.rs b/src/cargo/core/compiler/compilation.rs
index 8ec625d77..405b17b98 100644
--- a/src/cargo/core/compiler/compilation.rs
+++ b/src/cargo/core/compiler/compilation.rs
@@ -356,7 +356,6 @@ impl<'gctx> Compilation<'gctx> {
         // in BuildContext::target_metadata()
         let rust_version = pkg.rust_version().as_ref().map(ToString::to_string);
         cmd.env("CARGO_MANIFEST_DIR", pkg.root())
-            .env("CARGO_MANIFEST_PATH", pkg.manifest_path())
             .env("CARGO_PKG_VERSION_MAJOR", &pkg.version().major.to_string())
             .env("CARGO_PKG_VERSION_MINOR", &pkg.version().minor.to_string())
             .env("CARGO_PKG_VERSION_PATCH", &pkg.version().patch.to_string())
diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs
index f36e741c6..706783d93 100644
--- a/src/cargo/core/compiler/custom_build.rs
+++ b/src/cargo/core/compiler/custom_build.rs
@@ -279,7 +279,6 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
     let debug = unit.profile.debuginfo.is_turned_on();
     cmd.env("OUT_DIR", &script_out_dir)
         .env("CARGO_MANIFEST_DIR", unit.pkg.root())
-        .env("CARGO_MANIFEST_PATH", unit.pkg.manifest_path())
         .env("NUM_JOBS", &bcx.jobs().to_string())
         .env("TARGET", bcx.target_data.short_name(&unit.kind))
         .env("DEBUG", debug.to_string())
diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs
index 83c918a03..4592fdfa3 100644
--- a/src/cargo/core/compiler/mod.rs
+++ b/src/cargo/core/compiler/mod.rs
@@ -1867,10 +1867,19 @@ fn on_stderr_line_inner(
 
     #[derive(serde::Deserialize)]
     struct CompilerMessage {
+        message: String,
         level: String,
     }
-    if let Ok(message) = serde_json::from_str::<CompilerMessage>(compiler_message.get()) {
-        count_diagnostic(&message.level, options);
+
+    if let Ok(msg) = serde_json::from_str::<CompilerMessage>(compiler_message.get()) {
+        if msg.message.starts_with("aborting due to")
+            || msg.message.ends_with("warning emitted")
+            || msg.message.ends_with("warnings emitted")
+        {
+            // Skip this line; we'll print our own summary at the end.
+            return Ok(true);
+        }
+        count_diagnostic(&msg.level, options);
     }
 
     let msg = machine_message::FromCompiler {
diff --git a/src/cargo/core/compiler/timings.js b/src/cargo/core/compiler/timings.js
index d9a0b53bd..1b7e29e01 100644
--- a/src/cargo/core/compiler/timings.js
+++ b/src/cargo/core/compiler/timings.js
@@ -22,21 +22,6 @@ let UNIT_COORDS = {};
 // Map of unit index to the index it was unlocked by.
 let REVERSE_UNIT_DEPS = {};
 let REVERSE_UNIT_RMETA_DEPS = {};
-
-// Colors from css
-const getCssColor = name => getComputedStyle(document.body).getPropertyValue(name);
-const TEXT_COLOR = getCssColor('--text');
-const BG_COLOR = getCssColor('--background');
-const CANVAS_BG = getCssColor('--canvas-background');
-const AXES_COLOR = getCssColor('--canvas-axes');
-const GRID_COLOR = getCssColor('--canvas-grid');
-const BLOCK_COLOR = getCssColor('--canvas-block');
-const CUSTOM_BUILD_COLOR = getCssColor('--canvas-custom-build');
-const NOT_CUSTOM_BUILD_COLOR = getCssColor('--canvas-not-custom-build');
-const DEP_LINE_COLOR = getCssColor('--canvas-dep-line');
-const DEP_LINE_HIGHLIGHTED_COLOR = getCssColor('--canvas-dep-line-highlighted');
-const CPU_COLOR = getCssColor('--canvas-cpu');
-
 for (let n=0; n<UNIT_DATA.length; n++) {
   let unit = UNIT_DATA[n];
   for (let unlocked of unit.unlocked_units) {
@@ -67,7 +52,7 @@ function render_pipeline_graph() {
   // Canvas for hover highlights. This is a separate layer to improve performance.
   const linectx = setup_canvas('pipeline-graph-lines', canvas_width, canvas_height);
   linectx.clearRect(0, 0, canvas_width, canvas_height);
-  ctx.strokeStyle = AXES_COLOR;
+
   // Draw Y tick marks.
   for (let n=1; n<units.length; n++) {
     const y = MARGIN + Y_TICK_DIST * n;
@@ -80,7 +65,6 @@ function render_pipeline_graph() {
   // Draw Y labels.
   ctx.textAlign = 'end';
   ctx.textBaseline = 'middle';
-  ctx.fillStyle = AXES_COLOR;
   for (let n=0; n<units.length; n++) {
     let y = MARGIN + Y_TICK_DIST * n + Y_TICK_DIST / 2;
     ctx.fillText(n+1, X_LINE-4, y);
@@ -117,18 +101,18 @@ function render_pipeline_graph() {
     HIT_BOXES.push({x: X_LINE+x, y:MARGIN+y, x2: X_LINE+x+width, y2: MARGIN+y+BOX_HEIGHT, i: unit.i});
 
     ctx.beginPath();
-    ctx.fillStyle = unit.mode == 'run-custom-build' ? CUSTOM_BUILD_COLOR : NOT_CUSTOM_BUILD_COLOR;
+    ctx.fillStyle = unit.mode == 'run-custom-build' ? '#f0b165' : '#95cce8';
     roundedRect(ctx, x, y, width, BOX_HEIGHT, RADIUS);
     ctx.fill();
 
     if (unit.rmeta_time != null) {
       ctx.beginPath();
-      ctx.fillStyle = BLOCK_COLOR;
+      ctx.fillStyle = '#aa95e8';
       let ctime = unit.duration - unit.rmeta_time;
       roundedRect(ctx, rmeta_x, y, px_per_sec * ctime, BOX_HEIGHT, RADIUS);
       ctx.fill();
     }
-    ctx.fillStyle = TEXT_COLOR;
+    ctx.fillStyle = "#000";
     ctx.textAlign = 'start';
     ctx.textBaseline = 'middle';
     ctx.font = '14px sans-serif';
@@ -161,7 +145,7 @@ function draw_dep_lines(ctx, unit_idx, highlighted) {
 function draw_one_dep_line(ctx, from_x, from_y, to_unit, highlighted) {
   if (to_unit in UNIT_COORDS) {
     let {x: u_x, y: u_y} = UNIT_COORDS[to_unit];
-    ctx.strokeStyle = highlighted ? DEP_LINE_HIGHLIGHTED_COLOR: DEP_LINE_COLOR;
+    ctx.strokeStyle = highlighted ? '#000' : '#ddd';
     ctx.setLineDash([2]);
     ctx.beginPath();
     ctx.moveTo(from_x, from_y+BOX_HEIGHT/2);
@@ -220,7 +204,7 @@ function render_timing_graph() {
     };
   }
 
-  const cpuFillStyle = CPU_COLOR;
+  const cpuFillStyle = 'rgba(250, 119, 0, 0.2)';
   if (CPU_USAGE.length > 1) {
     ctx.beginPath();
     ctx.fillStyle = cpuFillStyle;
@@ -261,8 +245,8 @@ function render_timing_graph() {
   ctx.save();
   ctx.translate(canvas_width-200, MARGIN);
   // background
-  ctx.fillStyle = BG_COLOR;
-  ctx.strokeStyle = TEXT_COLOR;
+  ctx.fillStyle = '#fff';
+  ctx.strokeStyle = '#000';
   ctx.lineWidth = 1;
   ctx.textBaseline = 'middle'
   ctx.textAlign = 'start';
@@ -271,7 +255,7 @@ function render_timing_graph() {
   ctx.stroke();
   ctx.fill();
 
-  ctx.fillStyle = TEXT_COLOR;
+  ctx.fillStyle = '#000'
   ctx.beginPath();
   ctx.lineWidth = 2;
   ctx.strokeStyle = 'red';
@@ -298,7 +282,7 @@ function render_timing_graph() {
   ctx.fillStyle = cpuFillStyle
   ctx.fillRect(15, 60, 30, 15);
   ctx.fill();
-  ctx.fillStyle = TEXT_COLOR;
+  ctx.fillStyle = 'black';
   ctx.fillText('CPU Usage', 54, 71);
 
   ctx.restore();
@@ -327,13 +311,12 @@ function draw_graph_axes(id, graph_height) {
   const canvas_width = Math.max(graph_width + X_LINE + 30, X_LINE + 250);
   const canvas_height = graph_height + MARGIN + Y_LINE;
   let ctx = setup_canvas(id, canvas_width, canvas_height);
-  ctx.fillStyle = CANVAS_BG;
+  ctx.fillStyle = '#f7f7f7';
   ctx.fillRect(0, 0, canvas_width, canvas_height);
 
   ctx.lineWidth = 2;
   ctx.font = '16px sans-serif';
   ctx.textAlign = 'center';
-  ctx.strokeStyle = AXES_COLOR;
 
   // Draw main axes.
   ctx.beginPath();
@@ -344,7 +327,7 @@ function draw_graph_axes(id, graph_height) {
 
   // Draw X tick marks.
   const {step, tick_dist, num_ticks} = split_ticks(DURATION, px_per_sec, graph_width);
-  ctx.fillStyle = AXES_COLOR;
+  ctx.fillStyle = '#303030';
   for (let n=0; n<num_ticks; n++) {
     const x = X_LINE + ((n + 1) * tick_dist);
     ctx.beginPath();
@@ -356,7 +339,7 @@ function draw_graph_axes(id, graph_height) {
   }
 
   // Draw vertical lines.
-  ctx.strokeStyle = GRID_COLOR;
+  ctx.strokeStyle = '#e6e6e6';
   ctx.setLineDash([2, 4]);
   for (n=0; n<num_ticks; n++) {
     const x = X_LINE + ((n + 1) * tick_dist);
@@ -365,7 +348,7 @@ function draw_graph_axes(id, graph_height) {
     ctx.lineTo(x, MARGIN+graph_height);
     ctx.stroke();
   }
-  ctx.strokeStyle = TEXT_COLOR;
+  ctx.strokeStyle = '#000';
   ctx.setLineDash([]);
   return {canvas_width, canvas_height, graph_width, graph_height, ctx, px_per_sec};
 }
diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs
index 05d37632e..d6cfa1ba7 100644
--- a/src/cargo/core/compiler/timings.rs
+++ b/src/cargo/core/compiler/timings.rs
@@ -609,64 +609,8 @@ static HTML_TMPL: &str = r#"
   <title>Cargo Build Timings — {ROOTS}</title>
   <meta charset="utf-8">
 <style type="text/css">
-:root {
-  --error-text: #e80000;
-  --text: #000;
-  --background: #fff;
-  --h1-border-bottom: #c0c0c0;
-  --table-box-shadow: rgba(0, 0, 0, 0.1);
-  --table-th: #d5dde5;
-  --table-th-background: #1b1e24;
-  --table-th-border-bottom: #9ea7af;
-  --table-th-border-right: #343a45;
-  --table-tr-border-top: #c1c3d1;
-  --table-tr-border-bottom: #c1c3d1;
-  --table-tr-odd-background: #ebebeb;
-  --table-td-background: #ffffff;
-  --table-td-border-right: #C1C3D1;
-  --canvas-background: #f7f7f7;
-  --canvas-axes: #303030;
-  --canvas-grid: #e6e6e6;
-  --canvas-block: #aa95e8;
-  --canvas-custom-build: #f0b165;
-  --canvas-not-custom-build: #95cce8;
-  --canvas-dep-line: #ddd;
-  --canvas-dep-line-highlighted: #000;
-  --canvas-cpu: rgba(250, 119, 0, 0.2);
-}
-
-@media (prefers-color-scheme: dark) {
-  :root {
-    --error-text: #e80000;
-    --text: #fff;
-    --background: #121212;
-    --h1-border-bottom: #444;
-    --table-box-shadow: rgba(255, 255, 255, 0.1);
-    --table-th: #a0a0a0;
-    --table-th-background: #2c2c2c;
-    --table-th-border-bottom: #555;
-    --table-th-border-right: #444;
-    --table-tr-border-top: #333;
-    --table-tr-border-bottom: #333;
-    --table-tr-odd-background: #1e1e1e;
-    --table-td-background: #262626;
-    --table-td-border-right: #333;
-    --canvas-background: #1a1a1a;
-    --canvas-axes: #b0b0b0;
-    --canvas-grid: #333;
-    --canvas-block: #aa95e8;
-    --canvas-custom-build: #f0b165;
-    --canvas-not-custom-build: #95cce8;
-    --canvas-dep-line: #444;
-    --canvas-dep-line-highlighted: #fff;
-    --canvas-cpu: rgba(250, 119, 0, 0.2);
-  }
-}
-
 html {
   font-family: sans-serif;
-  color: var(--text);
-  background: var(--background);
 }
 
 .canvas-container {
@@ -676,7 +620,7 @@ html {
 }
 
 h1 {
-  border-bottom: 1px solid var(--h1-border-bottom);
+  border-bottom: 1px solid #c0c0c0;
 }
 
 .graph {
@@ -687,14 +631,14 @@ h1 {
   margin-top: 20px;
   margin-bottom: 20px;
   border-collapse: collapse;
-  box-shadow: 0 5px 10px var(--table-box-shadow);
+  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
 }
 
 .my-table th {
-  color: var(--table-th);
-  background: var(--table-th-background);
-  border-bottom: 4px solid var(--table-th-border-bottom);
-  border-right: 1px solid var(--table-th-border-right);
+  color: #d5dde5;
+  background: #1b1e24;
+  border-bottom: 4px solid #9ea7af;
+  border-right: 1px solid #343a45;
   font-size: 18px;
   font-weight: 100;
   padding: 12px;
@@ -712,8 +656,8 @@ h1 {
 }
 
 .my-table tr {
-  border-top: 1px solid var(--table-tr-border-top);
-  border-bottom: 1px solid var(--table-tr-border-bottom);
+  border-top: 1px solid #c1c3d1;
+  border-bottom: 1px solid #c1c3d1;
   font-size: 16px;
   font-weight: normal;
 }
@@ -727,7 +671,7 @@ h1 {
 }
 
 .my-table tr:nth-child(odd) td {
-  background: var(--table-tr-odd-background);
+  background: #ebebeb;
 }
 
 .my-table tr:last-child td:first-child {
@@ -739,13 +683,13 @@ h1 {
 }
 
 .my-table td {
-  background: var(--table-td-background);
+  background: #ffffff;
   padding: 10px;
   text-align: left;
   vertical-align: middle;
   font-weight: 300;
   font-size: 14px;
-  border-right: 1px solid var(--table-td-border-right);
+  border-right: 1px solid #C1C3D1;
 }
 
 .my-table td:last-child {
@@ -762,7 +706,7 @@ h1 {
 }
 
 .error-text {
-  color: var(--error-text);
+  color: #e80000;
 }
 
 </style>
diff --git a/src/cargo/util/context/mod.rs b/src/cargo/util/context/mod.rs
index ab283aa24..1db5b9a3c 100644
--- a/src/cargo/util/context/mod.rs
+++ b/src/cargo/util/context/mod.rs
@@ -1581,21 +1581,20 @@ impl GlobalContext {
     where
         F: FnMut(&Path) -> CargoResult<()>,
     {
-        let mut seen_dir = HashSet::new();
+        let mut stash: HashSet<PathBuf> = HashSet::new();
 
         for current in paths::ancestors(pwd, self.search_stop_path.as_deref()) {
-            let config_root = current.join(".cargo");
-            if let Some(path) = self.get_file_path(&config_root, "config", true)? {
+            if let Some(path) = self.get_file_path(&current.join(".cargo"), "config", true)? {
                 walk(&path)?;
+                stash.insert(path);
             }
-            seen_dir.insert(config_root);
         }
 
         // Once we're done, also be sure to walk the home directory even if it's not
         // in our history to be sure we pick up that standard location for
         // information.
-        if !seen_dir.contains(home) {
-            if let Some(path) = self.get_file_path(home, "config", true)? {
+        if let Some(path) = self.get_file_path(home, "config", true)? {
+            if !stash.contains(&path) {
                 walk(&path)?;
             }
         }
diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md
index 415e68918..3a7053675 100644
--- a/src/doc/src/reference/environment-variables.md
+++ b/src/doc/src/reference/environment-variables.md
@@ -226,7 +226,6 @@ corresponding environment variable is set to the empty string, `""`.
 
 * `CARGO` --- Path to the `cargo` binary performing the build.
 * `CARGO_MANIFEST_DIR` --- The directory containing the manifest of your package.
-* `CARGO_MANIFEST_PATH` --- The path to the manifest of your package.
 * `CARGO_PKG_VERSION` --- The full version of your package.
 * `CARGO_PKG_VERSION_MAJOR` --- The major version of your package.
 * `CARGO_PKG_VERSION_MINOR` --- The minor version of your package.
@@ -321,7 +320,6 @@ let out_dir = env::var("OUT_DIR").unwrap();
 * `CARGO_MANIFEST_DIR` --- The directory containing the manifest for the package
   being built (the package containing the build script). Also note that this is
   the value of the current working directory of the build script when it starts.
-* `CARGO_MANIFEST_PATH` --- The path to the manifest of your package.
 * `CARGO_MANIFEST_LINKS` --- the manifest `links` value.
 * `CARGO_MAKEFLAGS` --- Contains parameters needed for Cargo's [jobserver]
   implementation to parallelize subprocesses. Rustc or cargo invocations from
diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md
index 20f2175b7..84c08860e 100644
--- a/src/doc/src/reference/unstable.md
+++ b/src/doc/src/reference/unstable.md
@@ -1466,7 +1466,7 @@ This will not affect any hard-coded paths in the source code, such as in strings
     Values in a non-empty array would be joined into a comma-separated list.
     If the build script introduces absolute paths to built artifacts (such as by invoking a compiler),
     the user may request them to be sanitized in different types of artifacts.
-    Common paths requiring sanitization include `OUT_DIR`, `CARGO_MANIFEST_DIR` and `CARGO_MANIFEST_PATH`,
+    Common paths requiring sanitization include `OUT_DIR` and `CARGO_MANIFEST_DIR`,
     plus any other introduced by the build script, such as include directories.
 
 ## gc


Test patch:
diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs
index 289b25f19..3182f6261 100644
--- a/tests/testsuite/build.rs
+++ b/tests/testsuite/build.rs
@@ -95,7 +95,7 @@ fn cargo_fail_with_no_stderr() {
         .with_status(101)
         .with_stderr_data(str![[r#"
 [COMPILING] foo v0.5.0 ([ROOT]/foo)
-[ERROR] could not compile `foo` (bin "foo") due to 2 previous errors
+[ERROR] could not compile `foo` (bin "foo") due to 1 previous error
 
 "#]])
         .run();
@@ -1623,7 +1623,6 @@ fn crate_env_vars() {
                 static VERSION_PRE: &'static str = env!("CARGO_PKG_VERSION_PRE");
                 static VERSION: &'static str = env!("CARGO_PKG_VERSION");
                 static CARGO_MANIFEST_DIR: &'static str = env!("CARGO_MANIFEST_DIR");
-                static CARGO_MANIFEST_PATH: &'static str = env!("CARGO_MANIFEST_PATH");
                 static PKG_NAME: &'static str = env!("CARGO_PKG_NAME");
                 static HOMEPAGE: &'static str = env!("CARGO_PKG_HOMEPAGE");
                 static REPOSITORY: &'static str = env!("CARGO_PKG_REPOSITORY");
@@ -1637,9 +1636,9 @@ fn crate_env_vars() {
 
 
                 fn main() {
-                    let s = format!("{}-{}-{} @ {} in {} file {}", VERSION_MAJOR,
+                    let s = format!("{}-{}-{} @ {} in {}", VERSION_MAJOR,
                                     VERSION_MINOR, VERSION_PATCH, VERSION_PRE,
-                                    CARGO_MANIFEST_DIR, CARGO_MANIFEST_PATH);
+                                    CARGO_MANIFEST_DIR);
                      assert_eq!(s, foo::version());
                      println!("{}", s);
                      assert_eq!("foo", PKG_NAME);
@@ -1673,13 +1672,12 @@ fn crate_env_vars() {
                 use std::path::PathBuf;
 
                 pub fn version() -> String {
-                    format!("{}-{}-{} @ {} in {} file {}",
+                    format!("{}-{}-{} @ {} in {}",
                             env!("CARGO_PKG_VERSION_MAJOR"),
                             env!("CARGO_PKG_VERSION_MINOR"),
                             env!("CARGO_PKG_VERSION_PATCH"),
                             env!("CARGO_PKG_VERSION_PRE"),
-                            env!("CARGO_MANIFEST_DIR"),
-                            env!("CARGO_MANIFEST_PATH"))
+                            env!("CARGO_MANIFEST_DIR"))
                 }
 
                 pub fn check_no_int_test_env() {
@@ -1795,7 +1793,7 @@ fn crate_env_vars() {
     println!("bin");
     p.process(&p.bin("foo-bar"))
         .with_stdout_data(str![[r#"
-0-5-1 @ alpha.1 in [ROOT]/foo file [ROOT]/foo/Cargo.toml
+0-5-1 @ alpha.1 in [ROOT]/foo
 
 "#]])
         .run();
@@ -1863,15 +1861,12 @@ fn cargo_rustc_current_dir_foreign_workspace_dep() {
             fn baz_env() {
                 let workspace_dir = Path::new(option_env!("CARGO_RUSTC_CURRENT_DIR").expect("CARGO_RUSTC_CURRENT_DIR"));
                 let manifest_dir = Path::new(option_env!("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
-                let manifest_path = Path::new(option_env!("CARGO_MANIFEST_PATH").expect("CARGO_MANIFEST_PATH"));
                 let current_dir = std::env::current_dir().expect("current_dir");
                 let file_path = workspace_dir.join(file!());
                 assert!(file_path.exists(), "{}", file_path.display());
                 let workspace_dir = std::fs::canonicalize(current_dir.join(workspace_dir)).expect("CARGO_RUSTC_CURRENT_DIR");
-                let manifest_path = std::fs::canonicalize(current_dir.join(manifest_dir.clone()).join("Cargo.toml")).expect("CARGO_MANIFEST_PATH");
                 let manifest_dir = std::fs::canonicalize(current_dir.join(manifest_dir)).expect("CARGO_MANIFEST_DIR");
-                assert_eq!(workspace_dir, manifest_dir.clone());
-                assert_eq!(manifest_dir.join("Cargo.toml"), manifest_path);
+                assert_eq!(workspace_dir, manifest_dir);
             }
         "#,
         )
@@ -1960,15 +1955,12 @@ fn cargo_rustc_current_dir_non_local_dep() {
             fn bar_env() {
                 let workspace_dir = Path::new(option_env!("CARGO_RUSTC_CURRENT_DIR").expect("CARGO_RUSTC_CURRENT_DIR"));
                 let manifest_dir = Path::new(option_env!("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
-                let manifest_path = Path::new(option_env!("CARGO_MANIFEST_PATH").expect("CARGO_MANIFEST_PATH"));
                 let current_dir = std::env::current_dir().expect("current_dir");
                 let file_path = workspace_dir.join(file!());
                 assert!(file_path.exists(), "{}", file_path.display());
                 let workspace_dir = std::fs::canonicalize(current_dir.join(workspace_dir)).expect("CARGO_RUSTC_CURRENT_DIR");
-                let manifest_path = std::fs::canonicalize(current_dir.join(manifest_dir.clone()).join("Cargo.toml")).expect("CARGO_MANIFEST_PATH");
                 let manifest_dir = std::fs::canonicalize(current_dir.join(manifest_dir)).expect("CARGO_MANIFEST_DIR");
-                assert_eq!(workspace_dir, manifest_dir.clone());
-                assert_eq!(manifest_dir.join("Cargo.toml"), manifest_path);
+                assert_eq!(workspace_dir, manifest_dir);
             }
         "#,
         )
diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs
index 8f9092c2f..6d0a3ff8e 100644
--- a/tests/testsuite/config.rs
+++ b/tests/testsuite/config.rs
@@ -16,7 +16,7 @@ use cargo::CargoResult;
 use cargo_test_support::compare::assert_e2e;
 use cargo_test_support::prelude::*;
 use cargo_test_support::str;
-use cargo_test_support::{paths, project, project_in_home, symlink_supported, t};
+use cargo_test_support::{paths, project, symlink_supported, t};
 use cargo_util_schemas::manifest::TomlTrimPaths;
 use cargo_util_schemas::manifest::TomlTrimPathsValue;
 use cargo_util_schemas::manifest::{self as cargo_toml, TomlDebugInfo, VecStringOrBool as VSOB};
@@ -299,26 +299,6 @@ f1 = 1
     assert_e2e().eq(&output, expected);
 }
 
-#[cargo_test]
-fn home_config_works_without_extension() {
-    write_config_at(
-        paths::cargo_home().join("config"),
-        "\
-[foo]
-f1 = 1
-",
-    );
-    let p = project_in_home("foo").file("src/lib.rs", "").build();
-
-    p.cargo("-vV")
-        .with_stderr_data(str![[r#"
-[WARNING] `[ROOT]/home/.cargo/config` is deprecated in favor of `config.toml`
-[NOTE] if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
-
-"#]])
-        .run();
-}
-
 #[cargo_test]
 fn config_ambiguous_filename_symlink_doesnt_warn() {
     // Windows requires special permissions to create symlinks.
diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs
index 4bcd2800c..287301159 100644
--- a/tests/testsuite/freshness.rs
+++ b/tests/testsuite/freshness.rs
@@ -1891,7 +1891,6 @@ test t1 ... FAILED
 failures:
 
 ---- t1 stdout ----
-...
 thread 't1' panicked at src/lib.rs:8:21:
 assertion `left == right` failed: doit assert failure
   left: 2
@@ -1959,7 +1958,6 @@ Caused by:
   cargo::rerun-if-changed=build.rs
 
   --- stderr
-...
   thread 'main' panicked at helper.rs:1:16:
   Crash!
   [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -1979,7 +1977,6 @@ Caused by:
   cargo::rerun-if-changed=build.rs
 
   --- stderr
-...
   thread 'main' panicked at helper.rs:1:16:
   Crash!
   [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs
index 95656cc83..c17ae2577 100644
--- a/tests/testsuite/install.rs
+++ b/tests/testsuite/install.rs
@@ -1327,7 +1327,6 @@ fn reports_unsuccessful_subcommand_result() {
     cargo_process("fail")
         .with_status(101)
         .with_stderr_data(str![[r#"
-...
 thread 'main' panicked at [ROOT]/home/.cargo/registry/src/-[HASH]/cargo-fail-1.0.0/src/main.rs:1:13:
 explicit panic
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
diff --git a/tests/testsuite/jobserver.rs b/tests/testsuite/jobserver.rs
index e6902c4b2..108b5d3a3 100644
--- a/tests/testsuite/jobserver.rs
+++ b/tests/testsuite/jobserver.rs
@@ -232,7 +232,6 @@ this is a runner
         .with_stderr_data(str![[r#"
 [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
 [RUNNING] `target/debug/cargo-jobserver-check[EXE]`
-...
 thread 'main' panicked at src/main.rs:5:43:
 no jobserver from env: NotPresent
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -249,11 +248,9 @@ no jobserver from env: NotPresent
 [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
 [RUNNING] `runner target/debug/cargo-jobserver-check[EXE]`
 this is a runner
-...
 thread 'main' panicked at src/main.rs:5:43:
 no jobserver from env: NotPresent
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
-...
 thread 'main' panicked at src/main.rs:6:17:
 assertion failed: status.success()
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -271,7 +268,6 @@ test test ... FAILED
 failures:
 
 ---- test stdout ----
-...
 thread 'test' panicked at src/lib.rs:4:42:
 no jobserver from env: NotPresent
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -294,7 +290,6 @@ test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out;
 [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
 [RUNNING] unittests src/lib.rs (target/debug/deps/cargo_jobserver_check-[HASH][EXE])
 this is a runner
-...
 thread 'main' panicked at src/main.rs:6:17:
 assertion failed: status.success()
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@@ -309,7 +304,6 @@ test test ... FAILED
 failures:
 
 ---- test stdout ----
-...
 thread 'test' panicked at src/lib.rs:4:42:
 no jobserver from env: NotPresent
 [NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
diff --git a/tests/testsuite/pkgid.rs b/tests/testsuite/pkgid.rs
index bdfc4a4bf..026560316 100644
--- a/tests/testsuite/pkgid.rs
+++ b/tests/testsuite/pkgid.rs
@@ -327,12 +327,6 @@ fn pkgid_json_message_metadata_consistency() {
     "reason": "compiler-message",
     "...": "{...}"
   },
-  {
-    "manifest_path": "[ROOT]/foo/Cargo.toml",
-    "package_id": "path+[ROOTURL]/foo#0.5.0",
-    "reason": "compiler-message",
-    "...": "{...}"
-  },
   {
     "manifest_path": "[ROOT]/foo/Cargo.toml",
     "package_id": "path+[ROOTURL]/foo#0.5.0",
diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs
index 6cf34b4e4..1ad98ed5d 100644
--- a/tests/testsuite/script.rs
+++ b/tests/testsuite/script.rs
@@ -1317,33 +1317,3 @@ fn cmd_publish_with_embedded() {
 "#]])
         .run();
 }
-
-#[cargo_test]
-fn manifest_path_env() {
-    let p = cargo_test_support::project()
-        .file(
-            "script.rs",
-            r#"#!/usr/bin/env cargo
-
-fn main() {
-    let path = env!("CARGO_MANIFEST_PATH");
-    println!("CARGO_MANIFEST_PATH: {}", path);
-}
-"#,
-        )
-        .build();
-    p.cargo("-Zscript -v script.rs")
-        .masquerade_as_nightly_cargo(&["script"])
-        .with_stdout_data(str![[r#"
-CARGO_MANIFEST_PATH: [ROOT]/foo/script.rs
-
-"#]])
-        .with_stderr_data(str![[r#"
-[WARNING] `package.edition` is unspecified, defaulting to `2021`
-[COMPILING] script v0.0.0 ([ROOT]/foo)
-[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
-[RUNNING] `[ROOT]/home/.cargo/target/[HASH]/debug/script[EXE]`
-
-"#]])
-        .run();
-}
diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs
index 4c209e819..193e0cfe5 100644
--- a/tests/testsuite/test.rs
+++ b/tests/testsuite/test.rs
@@ -516,7 +516,6 @@ test test_hello ... FAILED
 failures:
 
 ---- test_hello stdout ----
-...
 thread 'test_hello' panicked at src/lib.rs:1:27:
 assertion failed: false
 ...