Skip to content

Commit faeaedc

Browse files
Rollup merge of #153797 - Ozzy1423:comp-lines, r=jieyouxu
Compiletest: Fix compare-output-by-lines directive Fixes: #148235 This was checking that the blessed stderr was a subset of the stderr. Additionally, when re-blessing it would re-bless the subset that matched. So, when an extra line or comment was added and the line numbers changed, it would bless it without the line numbers. I hope this is the intended behaviour now, my only concern is if the parallel frontend has cases where it sometimes emits less diagnostics than other times and so re-blessing the minimum was the intended behaviour? There used to be a flag called "compare-output-by-lines-subset" for this which used this logic. r? @jieyouxu
2 parents c631490 + 772e456 commit faeaedc

5 files changed

Lines changed: 47 additions & 18 deletions

File tree

src/tools/compiletest/src/runtest.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,18 +2718,19 @@ impl<'test> TestCx<'test> {
27182718
// Wrapper tools set by `runner` might provide extra output on failure,
27192719
// for example a WebAssembly runtime might print the stack trace of an
27202720
// `unreachable` instruction by default.
2721-
//
2721+
let compare_output_by_lines_subset = self.config.runner.is_some();
2722+
27222723
// Also, some tests like `ui/parallel-rustc` have non-deterministic
27232724
// orders of output, so we need to compare by lines.
2724-
let compare_output_by_lines =
2725-
self.props.compare_output_by_lines || self.config.runner.is_some();
2725+
let compare_output_by_lines = self.props.compare_output_by_lines;
27262726

27272727
let tmp;
2728-
let (expected, actual): (&str, &str) = if compare_output_by_lines {
2728+
let (expected, actual): (&str, &str) = if compare_output_by_lines_subset {
27292729
let actual_lines: HashSet<_> = actual.lines().collect();
27302730
let expected_lines: Vec<_> = expected.lines().collect();
27312731
let mut used = expected_lines.clone();
27322732
used.retain(|line| actual_lines.contains(line));
2733+
27332734
// check if `expected` contains a subset of the lines of `actual`
27342735
if used.len() == expected_lines.len() && (expected.is_empty() == actual.is_empty()) {
27352736
return CompareOutcome::Same;
@@ -2738,9 +2739,20 @@ impl<'test> TestCx<'test> {
27382739
// if we have no lines to check, force a full overwite
27392740
("", actual)
27402741
} else {
2742+
// this prints/blesses the subset, not the actual
27412743
tmp = (expected_lines.join("\n"), used.join("\n"));
27422744
(&tmp.0, &tmp.1)
27432745
}
2746+
} else if compare_output_by_lines {
2747+
let mut actual_lines: Vec<&str> = actual.lines().collect();
2748+
let mut expected_lines: Vec<&str> = expected.lines().collect();
2749+
actual_lines.sort_unstable();
2750+
expected_lines.sort_unstable();
2751+
if actual_lines == expected_lines {
2752+
return CompareOutcome::Same;
2753+
} else {
2754+
(expected, actual)
2755+
}
27442756
} else {
27452757
(expected, actual)
27462758
};
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
error[E0391]: cycle detected when checking if `FOO` is a trivial const
12
--> $DIR/cycle_crash-issue-135870.rs:6:1
23
|
34
LL | const FOO: usize = FOO;
45
| ^^^^^^^^^^^^^^^^
56
|
7+
note: ...which requires building MIR for `FOO`...
8+
--> $DIR/cycle_crash-issue-135870.rs:6:1
9+
|
10+
LL | const FOO: usize = FOO;
11+
| ^^^^^^^^^^^^^^^^
12+
= note: ...which again requires checking if `FOO` is a trivial const, completing the cycle
13+
note: cycle used when simplifying constant for the type system `FOO`
14+
--> $DIR/cycle_crash-issue-135870.rs:6:1
615
|
716
LL | const FOO: usize = FOO;
17+
| ^^^^^^^^^^^^^^^^
818
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
919

1020
error: aborting due to 1 previous error
1121

12-
For more information about this error, try `rustc --explain E0391`.
22+
For more information about this error, try `rustc --explain E0391`.

tests/ui/parallel-rustc/ty-variance-issue-124423.stderr

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ LL | fn elided4(_: &impl Copy + 'a) -> new { x(x) }
244244
| ^^^ not found in this scope
245245

246246
error[E0224]: at least one trait is required for an object type
247-
--> $DIR/ty-variance-issue-124423.rs:35:39
247+
--> $DIR/ty-variance-issue-124423.rs:55:40
248248
|
249-
LL | fn elided3(_: &impl Copy + 'a) -> Box<dyn 'a> { Box::new(x) }
250-
| ^^^^^^
249+
LL | impl<'a> LifetimeTrait<'a> for &'a Box<dyn 'a> {}
250+
| ^^^^^^
251251

252252
error[E0224]: at least one trait is required for an object type
253253
--> $DIR/ty-variance-issue-124423.rs:41:40
@@ -256,10 +256,10 @@ LL | fn x<'b>(_: &'a impl Copy + 'a) -> Box<dyn 'b> { Box::u32(x) }
256256
| ^^^^^^
257257

258258
error[E0224]: at least one trait is required for an object type
259-
--> $DIR/ty-variance-issue-124423.rs:55:40
259+
--> $DIR/ty-variance-issue-124423.rs:35:39
260260
|
261-
LL | impl<'a> LifetimeTrait<'a> for &'a Box<dyn 'a> {}
262-
| ^^^^^^
261+
LL | fn elided3(_: &impl Copy + 'a) -> Box<dyn 'a> { Box::new(x) }
262+
| ^^^^^^
263263

264264
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
265265
--> $DIR/ty-variance-issue-124423.rs:8:34
@@ -278,6 +278,7 @@ note: if you're trying to build a new `Box<_, _>` consider using one of the foll
278278
Box::<T>::new_uninit
279279
Box::<T>::new_zeroed
280280
Box::<T>::try_new
281+
and 27 others
281282
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
282283

283284
error: aborting due to 30 previous errors

tests/ui/parallel-rustc/ty-variance-issue-127971.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ note: if you're trying to build a new `Box<_, _>` consider using one of the foll
104104
Box::<T>::new_uninit
105105
Box::<T>::new_zeroed
106106
Box::<T>::try_new
107+
and 27 others
107108
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
108109

109110
error: aborting due to 11 previous errors
110111

111112
Some errors have detailed explanations: E0121, E0224, E0261, E0599.
112-
For more information about an error, try `rustc --explain E0121`.
113+
For more information about an error, try `rustc --explain E0121`.

tests/ui/parallel-rustc/unexpected-type-issue-120601.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
error[E0670]: `async fn` is not permitted in Rust 2015
2+
--> $DIR/unexpected-type-issue-120601.rs:10:1
23
|
34
LL | async fn foo() -> Result<(), ()> {
45
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -7,6 +8,7 @@ LL | async fn foo() -> Result<(), ()> {
78
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
89

910
error[E0670]: `async fn` is not permitted in Rust 2015
11+
--> $DIR/unexpected-type-issue-120601.rs:16:1
1012
|
1113
LL | async fn tuple() -> Tuple {
1214
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -15,19 +17,16 @@ LL | async fn tuple() -> Tuple {
1517
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
1618

1719
error[E0670]: `async fn` is not permitted in Rust 2015
20+
--> $DIR/unexpected-type-issue-120601.rs:21:1
1821
|
1922
LL | async fn match_() {
2023
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
2124
|
2225
= help: pass `--edition 2024` to `rustc`
2326
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
2427

25-
error[E0425]: cannot find function, tuple struct or tuple variant `Unstable2` in this scope
26-
|
27-
LL | Unstable2(())
28-
| ^^^^^^^^^ not found in this scope
29-
3028
error[E0308]: mismatched types
29+
--> $DIR/unexpected-type-issue-120601.rs:23:9
3130
|
3231
LL | match tuple() {
3332
| ------- this expression has type `impl Future<Output = Tuple>`
@@ -41,7 +40,13 @@ help: consider `await`ing on the `Future`
4140
LL | match tuple().await {
4241
| ++++++
4342

43+
error[E0425]: cannot find function, tuple struct or tuple variant `Unstable2` in this scope
44+
--> $DIR/unexpected-type-issue-120601.rs:11:5
45+
|
46+
LL | Unstable2(())
47+
| ^^^^^^^^^ not found in this scope
48+
4449
error: aborting due to 5 previous errors
4550

4651
Some errors have detailed explanations: E0308, E0425, E0670.
47-
For more information about an error, try `rustc --explain E0308`.
52+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)