From 30451d6bcde806944cc801b2a9492c1b04dda169 Mon Sep 17 00:00:00 2001 From: Daria Sukhonina Date: Tue, 2 Jun 2026 12:53:25 +0300 Subject: [PATCH] Ignore diagnostic lines with a single "|" Inconsistency happens when subdiagnostic pads the main diagnostic with an empty source line (aka "|"). Meanwhile the parallel frontend might bunch subdiagnostics on a single primary diagnostic, removing padding from some other one. Revert "Update reproducibly failing tests when parallel frontend is enabled" This reverts commit f582193db55de1a111006d6b8e7e307b84950b4b. Apply a test directive format suggested by a reviewer Bless thine tests --- src/tools/compiletest/src/runtest.rs | 6 ++++-- src/tools/compiletest/src/runtest/compute_diff.rs | 5 +++-- .../2229_closure_analysis/diagnostics/liveness.rs | 2 +- .../non-snake-case/lint-uppercase-variables.rs | 2 +- tests/ui/lint/unused/unused-assign-148960.rs | 2 +- tests/ui/liveness/liveness-consts.rs | 2 +- tests/ui/liveness/liveness-dead.rs | 1 - tests/ui/liveness/liveness-dead.stderr | 10 +++++----- tests/ui/liveness/liveness-unused.rs | 2 +- tests/ui/liveness/liveness-upvars.rs | 2 +- ...ed-assignments-diverging-branch-issue-156416.rs | 2 +- .../empty-types.exhaustive_patterns.stderr | 2 +- .../usefulness/empty-types.never_pats.stderr | 2 +- .../pattern/usefulness/empty-types.normal.stderr | 2 +- tests/ui/pattern/usefulness/empty-types.rs | 14 +++++++------- .../edition-lint-infer-outlives-macro.fixed | 2 +- .../edition-lint-infer-outlives-macro.rs | 2 +- 17 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 79e04b12fbed3..27bbc56c36d1b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2719,8 +2719,10 @@ impl<'test> TestCx<'test> { (&tmp.0, &tmp.1) } } else if compare_output_by_lines { - let mut actual_lines: Vec<&str> = actual.lines().collect(); - let mut expected_lines: Vec<&str> = expected.lines().collect(); + // Filter out padded empty code lines + let mut actual_lines: Vec<&str> = actual.lines().filter(|l| l.trim() != "|").collect(); + let mut expected_lines: Vec<&str> = + expected.lines().filter(|l| l.trim() != "|").collect(); actual_lines.sort_unstable(); expected_lines.sort_unstable(); if actual_lines == expected_lines { diff --git a/src/tools/compiletest/src/runtest/compute_diff.rs b/src/tools/compiletest/src/runtest/compute_diff.rs index e03a5bfb36447..ce796d2820568 100644 --- a/src/tools/compiletest/src/runtest/compute_diff.rs +++ b/src/tools/compiletest/src/runtest/compute_diff.rs @@ -112,10 +112,11 @@ pub(crate) fn diff_by_lines(expected: &str, actual: &str) -> String { let mut expected_counts: HashMap<&str, usize> = HashMap::new(); let mut actual_counts: HashMap<&str, usize> = HashMap::new(); - for line in expected.lines() { + // Filter out padded empty code lines + for line in expected.lines().filter(|l| l.trim() != "|") { *expected_counts.entry(line).or_insert(0) += 1; } - for line in actual.lines() { + for line in actual.lines().filter(|l| l.trim() != "|") { *actual_counts.entry(line).or_insert(0) += 1; } diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs b/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs index e5f7ed3a8d774..1861fafb40514 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs @@ -1,6 +1,6 @@ //@ edition:2021 //@ check-pass -//@ ignore-parallel-frontend unstable liveness diagnostics + #![allow(unreachable_code)] #![warn(unused)] #![allow(dead_code)] diff --git a/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs b/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs index be3450494aaf2..aefbe63606a14 100644 --- a/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs +++ b/tests/ui/lint/non-snake-case/lint-uppercase-variables.rs @@ -1,7 +1,7 @@ #![warn(unused)] #![allow(dead_code)] #![deny(non_snake_case)] -//@ ignore-parallel-frontend `note`s on different source lines + mod foo { pub enum Foo { Foo } } diff --git a/tests/ui/lint/unused/unused-assign-148960.rs b/tests/ui/lint/unused/unused-assign-148960.rs index b7e129a4f2ab7..1adca1549fed8 100644 --- a/tests/ui/lint/unused/unused-assign-148960.rs +++ b/tests/ui/lint/unused/unused-assign-148960.rs @@ -1,5 +1,5 @@ //@ check-fail -//@ ignore-parallel-frontend unstable liveness diagnostics + #![deny(unused)] #![allow(dead_code)] diff --git a/tests/ui/liveness/liveness-consts.rs b/tests/ui/liveness/liveness-consts.rs index b239e12b2e021..5079c46ee7210 100644 --- a/tests/ui/liveness/liveness-consts.rs +++ b/tests/ui/liveness/liveness-consts.rs @@ -1,5 +1,5 @@ //@ check-pass -//@ ignore-parallel-frontend unstable liveness diagnostics + #![warn(unused)] #![allow(unreachable_code)] diff --git a/tests/ui/liveness/liveness-dead.rs b/tests/ui/liveness/liveness-dead.rs index c48b28ef74fec..004663c85ee50 100644 --- a/tests/ui/liveness/liveness-dead.rs +++ b/tests/ui/liveness/liveness-dead.rs @@ -1,4 +1,3 @@ -//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(dead_code)] #![deny(unused_assignments)] diff --git a/tests/ui/liveness/liveness-dead.stderr b/tests/ui/liveness/liveness-dead.stderr index 2288fae52091a..ade0e04d2e7a9 100644 --- a/tests/ui/liveness/liveness-dead.stderr +++ b/tests/ui/liveness/liveness-dead.stderr @@ -1,5 +1,5 @@ error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:10:24 + --> $DIR/liveness-dead.rs:9:24 | LL | let mut x: isize = 3; | ^ this value is reassigned later and never used @@ -7,13 +7,13 @@ LL | x = 4; | ----- `x` is overwritten here before the previous value is read | note: the lint level is defined here - --> $DIR/liveness-dead.rs:3:9 + --> $DIR/liveness-dead.rs:2:9 | LL | #![deny(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:18:5 + --> $DIR/liveness-dead.rs:17:5 | LL | x = 4; | ^^^^^ @@ -21,7 +21,7 @@ LL | x = 4; = help: maybe it is overwritten before being read? error: value passed to `x` is never read - --> $DIR/liveness-dead.rs:21:7 + --> $DIR/liveness-dead.rs:20:7 | LL | fn f4(mut x: i32) { | ^^^^^ @@ -29,7 +29,7 @@ LL | fn f4(mut x: i32) { = help: maybe it is overwritten before being read? error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:28:5 + --> $DIR/liveness-dead.rs:27:5 | LL | x = 4; | ^^^^^ diff --git a/tests/ui/liveness/liveness-unused.rs b/tests/ui/liveness/liveness-unused.rs index 95345c22b0411..a291d2489695f 100644 --- a/tests/ui/liveness/liveness-unused.rs +++ b/tests/ui/liveness/liveness-unused.rs @@ -3,7 +3,7 @@ #![deny(unused_assignments)] #![allow(dead_code, non_camel_case_types, trivial_numeric_casts, dropping_copy_types)] #![feature(intrinsics)] -//@ ignore-parallel-frontend `note`s on different source lines + use std::ops::AddAssign; fn f1(x: isize) { diff --git a/tests/ui/liveness/liveness-upvars.rs b/tests/ui/liveness/liveness-upvars.rs index 1a3d0e5be54ad..0d24fa1745cad 100644 --- a/tests/ui/liveness/liveness-upvars.rs +++ b/tests/ui/liveness/liveness-upvars.rs @@ -1,6 +1,6 @@ //@ edition:2018 //@ check-pass -//@ ignore-parallel-frontend unstable liveness diagnostics + #![feature(coroutines, stmt_expr_attributes)] #![warn(unused)] #![allow(unreachable_code)] diff --git a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs index d1fb55d874518..9c7bca0ee4610 100644 --- a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs +++ b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ ignore-parallel-frontend unstable liveness diagnostics + #![allow(dead_code)] #![warn(unused_assignments)] diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index d26ba93e72117..55a1b2edd27ad 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -9,7 +9,7 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:14:9 + --> $DIR/empty-types.rs:8:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index 4dcbe6ce677f9..507bc50ac7dd2 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -9,7 +9,7 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:14:9 + --> $DIR/empty-types.rs:8:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index a49050cedb4d0..d8bbce98f5b70 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -9,7 +9,7 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:14:9 + --> $DIR/empty-types.rs:8:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs index cb0f1813e915b..0a9913ff225c3 100644 --- a/tests/ui/pattern/usefulness/empty-types.rs +++ b/tests/ui/pattern/usefulness/empty-types.rs @@ -1,18 +1,18 @@ //@ revisions: normal exhaustive_patterns never_pats //@ edition: 2024 -//@ ignore-parallel-frontend pattern matching error message mismatch -// -// This tests correct handling of empty types in exhaustiveness checking. -// -// Most of the subtlety of this file happens in scrutinee places which are not required to hold -// valid data, namely dereferences and union field accesses. In these cases, empty arms can -// generally not be omitted, except with `exhaustive_patterns` which ignores this.. + #![feature(never_type)] #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(never_pats, feature(never_patterns))] #![allow(dead_code, unreachable_code)] #![deny(unreachable_patterns)] +// This tests correct handling of empty types in exhaustiveness checking. +// +// Most of the subtlety of this file happens in scrutinee places which are not required to hold +// valid data, namely dereferences and union field accesses. In these cases, empty arms can +// generally not be omitted, except with `exhaustive_patterns` which ignores this.. + #[derive(Copy, Clone)] enum Void {} diff --git a/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.fixed b/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.fixed index e7c10f71b831a..435857224ac31 100644 --- a/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.fixed +++ b/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.fixed @@ -1,7 +1,7 @@ //@ edition:2018 //@ aux-build:edition-lint-infer-outlives-macro.rs //@ run-rustfix -//@ ignore-parallel-frontend `note`s on different source lines + #![deny(explicit_outlives_requirements)] #![allow(dead_code)] diff --git a/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.rs b/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.rs index a39d766263e9a..6c879231a1681 100644 --- a/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.rs +++ b/tests/ui/rust-2018/edition-lint-inter-outlives/edition-lint-infer-outlives-macro.rs @@ -1,7 +1,7 @@ //@ edition:2018 //@ aux-build:edition-lint-infer-outlives-macro.rs //@ run-rustfix -//@ ignore-parallel-frontend `note`s on different source lines + #![deny(explicit_outlives_requirements)] #![allow(dead_code)]