Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2714,8 +2714,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
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the same filtering required for the compare_output_by_lines_subset scenario above?

View changes since the review

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 {
Expand Down
5 changes: 3 additions & 2 deletions src/tools/compiletest/src/runtest/compute_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ edition:2021

//@ check-pass
//@ ignore-parallel-frontend unstable liveness diagnostics
Copy link
Copy Markdown
Contributor

@petrochenkov petrochenkov Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could you keep nicer formatting while doing these changes, like

//@ directives (without empty lines)

#![attributes] (after an empty line)

other code (after an empty line)

(Here and in some other tests.)

View changes since the review

#![allow(unreachable_code)]
#![warn(unused)]
#![allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/non-snake-case/lint-uppercase-variables.rs
Original file line number Diff line number Diff line change
@@ -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 }
}
Expand Down
1 change: 0 additions & 1 deletion tests/ui/lint/unused/unused-assign-148960.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-fail
//@ ignore-parallel-frontend unstable liveness diagnostics
#![deny(unused)]
#![allow(dead_code)]

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/lint/unused/unused-assign-148960.stderr
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
error: value assigned to `value` is never read
--> $DIR/unused-assign-148960.rs:7:21
--> $DIR/unused-assign-148960.rs:6:21
|
LL | let mut value = b"0".to_vec();
| ^^^^^^^^^^^^^ this value is reassigned later and never used
LL | value = b"1".to_vec();
| ----- `value` is overwritten here before the previous value is read
|
note: the lint level is defined here
--> $DIR/unused-assign-148960.rs:3:9
--> $DIR/unused-assign-148960.rs:2:9
|
LL | #![deny(unused)]
| ^^^^^^
= note: `#[deny(unused_assignments)]` implied by `#[deny(unused)]`

error: value assigned to `x` is never read
--> $DIR/unused-assign-148960.rs:13:17
--> $DIR/unused-assign-148960.rs:12:17
|
LL | let mut x = 1;
| ^ this value is reassigned later and never used
LL | x = 2;
| ----- `x` is overwritten here before the previous value is read

error: value assigned to `x` is never read
--> $DIR/unused-assign-148960.rs:14:5
--> $DIR/unused-assign-148960.rs:13:5
|
LL | x = 2;
| ^^^^^ this value is reassigned later and never used
LL | x = 3;
| ----- `x` is overwritten here before the previous value is read

error: value assigned to `p` is never read
--> $DIR/unused-assign-148960.rs:25:17
--> $DIR/unused-assign-148960.rs:24:17
|
LL | let mut p = Point { x: 1, y: 1 };
| ^^^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used
LL | p = Point { x: 2, y: 2 };
| ------------------------ `p` is overwritten here before the previous value is read

error: variable `foo` is assigned to, but never used
--> $DIR/unused-assign-148960.rs:39:9
--> $DIR/unused-assign-148960.rs:38:9
|
LL | let mut foo = Foo;
| ^^^^^^^
Expand All @@ -52,7 +52,7 @@ LL + let Foo = Foo;
|

error: value assigned to `foo` is never read
--> $DIR/unused-assign-148960.rs:40:5
--> $DIR/unused-assign-148960.rs:39:5
|
LL | foo = Foo;
| ^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/liveness/liveness-consts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ check-pass
//@ ignore-parallel-frontend unstable liveness diagnostics
#![warn(unused)]
#![allow(unreachable_code)]

Expand Down
22 changes: 11 additions & 11 deletions tests/ui/liveness/liveness-consts.stderr
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
warning: unused variable: `e`
--> $DIR/liveness-consts.rs:27:13
--> $DIR/liveness-consts.rs:26:13
|
LL | let e = 1;
| ^ help: if this is intentional, prefix it with an underscore: `_e`
|
note: the lint level is defined here
--> $DIR/liveness-consts.rs:3:9
--> $DIR/liveness-consts.rs:2:9
|
LL | #![warn(unused)]
| ^^^^^^
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`

warning: unused variable: `s`
--> $DIR/liveness-consts.rs:36:24
--> $DIR/liveness-consts.rs:35:24
|
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
| ^ help: if this is intentional, prefix it with an underscore: `_s`

warning: unused variable: `z`
--> $DIR/liveness-consts.rs:36:55
--> $DIR/liveness-consts.rs:35:55
|
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
| ^ help: if this is intentional, prefix it with an underscore: `_z`

warning: variable `a` is assigned to, but never used
--> $DIR/liveness-consts.rs:8:9
--> $DIR/liveness-consts.rs:7:9
|
LL | let mut a = 0;
| ^^^^^
|
= note: consider using `_a` instead

warning: value assigned to `a` is never read
--> $DIR/liveness-consts.rs:12:9
--> $DIR/liveness-consts.rs:11:9
|
LL | a += 1;
| ^^^^^^
Expand All @@ -41,37 +41,37 @@ LL | a += 1;
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`

warning: value assigned to `b` is never read
--> $DIR/liveness-consts.rs:19:17
--> $DIR/liveness-consts.rs:18:17
|
LL | let mut b = 1;
| ^ this value is reassigned later and never used
LL | b += 1;
| ------ `b` is overwritten here before the previous value is read

warning: value assigned to `b` is never read
--> $DIR/liveness-consts.rs:20:5
--> $DIR/liveness-consts.rs:19:5
|
LL | b += 1;
| ^^^^^^ this value is reassigned later and never used
LL | b = 42;
| ------ `b` is overwritten here before the previous value is read

warning: unused variable: `z`
--> $DIR/liveness-consts.rs:63:13
--> $DIR/liveness-consts.rs:62:13
|
LL | let z = 42;
| ^ help: if this is intentional, prefix it with an underscore: `_z`

warning: value assigned to `t` is never read
--> $DIR/liveness-consts.rs:45:9
--> $DIR/liveness-consts.rs:44:9
|
LL | t = t + t;
| ^^^^^^^^^
|
= help: maybe it is overwritten before being read?

warning: unused variable: `w`
--> $DIR/liveness-consts.rs:52:13
--> $DIR/liveness-consts.rs:51:13
|
LL | let w = 10;
| ^ help: if this is intentional, prefix it with an underscore: `_w`
Expand Down
1 change: 0 additions & 1 deletion tests/ui/liveness/liveness-dead.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ ignore-parallel-frontend unstable liveness diagnostics
#![allow(dead_code)]
#![deny(unused_assignments)]

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/liveness/liveness-dead.stderr
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
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
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;
| ^^^^^
|
= 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) {
| ^^^^^
|
= 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;
| ^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/liveness/liveness-unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/liveness/liveness-upvars.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ edition:2018
//@ check-pass
//@ ignore-parallel-frontend unstable liveness diagnostics
#![feature(coroutines, stmt_expr_attributes)]
#![warn(unused)]
#![allow(unreachable_code)]
Expand Down
Loading
Loading