Skip to content

Commit f21602d

Browse files
Rollup merge of rust-lang#136865 - jieyouxu:long-type-path-compare-mode, r=lqd
Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes Fixes rust-lang#136510. ### Summary - Whereas previously `$TEST_BUILD_DIR` is a normalization of `/path/to/build/test/<test_suite_name>/`, we now more deeply normalize. `$TEST_BUILD_DIR` now becomes a normalization of `/path/to/build/test/<test_suite_name>/<subdirs>/$name.$revision.$compare_mode.$debugger/` to normalize away path name differences when `--compare-mode` and/or `--debugger` are specified. - We also centralize the normalization of long type name hashes cf. rust-lang#136328 (comment). ### Review advice - Best reviewed commit-by-commit. - Split into 3 commits: - **Commit 1**: compiletest changes to have `$TEST_BUILD_DIR` more deeply normalize. - **Commit 2**: remove per-test hacks for long type path hash normalizations, and rebless tests *specifically* affected by that. - **Commit 3**: rebless other tests that were changed as a side-effect of deeper `$TEST_BUILD_DIR` normalizations. **Commit 2** is created via first finding tests that try to perform long type file hash normalizations on an ad hoc, per-test basis: ``` rg --no-ignore -l --no-ignore -F -e "long-type" tests/ui/**/*.rs ``` <details> <summary>Tests with ad hoc long-type hash normalizations</summary> ``` tests/ui/type_length_limit.rs tests/ui/traits/on_unimplemented_long_types.rs tests/ui/regions/issue-102374.rs tests/ui/recursion/recursion.rs tests/ui/recursion/issue-83150.rs tests/ui/recursion/issue-23122-2.rs tests/ui/methods/inherent-bound-in-probe.rs tests/ui/issues/issue-67552.rs tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs tests/ui/issues/issue-20413.rs tests/ui/issues/issue-8727.rs tests/ui/infinite/infinite-instantiation.rs tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.rs tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs tests/ui/error-codes/E0275.rs tests/ui/diagnostic-width/secondary-label-with-long-type.rs tests/ui/diagnostic-width/long-e0277.rs tests/ui/diagnostic-width/non-copy-type-moved.rs tests/ui/diagnostic-width/long-E0308.rs tests/ui/diagnostic-width/E0271.rs tests/ui/diagnostic-width/binop.rs ``` </details> These ad hoc normalizations were removed, and they are reblessed. r? ```@lqd```
2 parents 0512a9b + 4f2a3dc commit f21602d

File tree

67 files changed

+143
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+143
-177
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,8 +2412,9 @@ impl<'test> TestCx<'test> {
24122412
let rust_src_dir = rust_src_dir.read_link().unwrap_or(rust_src_dir.to_path_buf());
24132413
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");
24142414

2415-
// eg. /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui
2416-
normalize_path(&self.config.build_test_suite_root, "$TEST_BUILD_DIR");
2415+
// eg.
2416+
// /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui/<test_dir>/$name.$revision.$mode/
2417+
normalize_path(&self.output_base_dir(), "$TEST_BUILD_DIR");
24172418
// eg. /home/user/rust/build
24182419
normalize_path(&self.config.build_root, "$BUILD_DIR");
24192420

@@ -2434,6 +2435,18 @@ impl<'test> TestCx<'test> {
24342435
.into_owned();
24352436

24362437
normalized = Self::normalize_platform_differences(&normalized);
2438+
2439+
// Normalize long type name hash.
2440+
normalized =
2441+
static_regex!(r"\$TEST_BUILD_DIR/(?P<filename>[^\.]+).long-type-(?P<hash>\d+).txt")
2442+
.replace_all(&normalized, |caps: &Captures<'_>| {
2443+
format!(
2444+
"$TEST_BUILD_DIR/{filename}.long-type-$LONG_TYPE_HASH.txt",
2445+
filename = &caps["filename"]
2446+
)
2447+
})
2448+
.into_owned();
2449+
24372450
normalized = normalized.replace("\t", "\\t"); // makes tabs visible
24382451

24392452
// Remove test annotations like `//~ ERROR text` from the output,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$TEST_BUILD_DIR/codegen-backend/hotplug.bindep/libhotplug.rlib: $DIR/hotplug.rs $TEST_BUILD_DIR/codegen-backend/hotplug.bindep/auxiliary/libthe_backend.so
1+
$TEST_BUILD_DIR/libhotplug.rlib: $DIR/hotplug.rs $TEST_BUILD_DIR/auxiliary/libthe_backend.so
22

33
$DIR/hotplug.rs:
4-
$TEST_BUILD_DIR/codegen-backend/hotplug.bindep/auxiliary/libthe_backend.so:
4+
$TEST_BUILD_DIR/auxiliary/libthe_backend.so:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
$TEST_BUILD_DIR/codegen-backend/hotplug.dep/libhotplug.rlib: $DIR/hotplug.rs
1+
$TEST_BUILD_DIR/libhotplug.rlib: $DIR/hotplug.rs
22

33
$DIR/hotplug.rs:

tests/ui/crate-loading/crateresolve1.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found
44
LL | extern crate crateresolve1;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: candidate #1: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-1.somelib
8-
= note: candidate #2: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-2.somelib
9-
= note: candidate #3: $TEST_BUILD_DIR/crate-loading/crateresolve1/auxiliary/libcrateresolve1-3.somelib
7+
= note: candidate #1: $TEST_BUILD_DIR/auxiliary/libcrateresolve1-1.somelib
8+
= note: candidate #2: $TEST_BUILD_DIR/auxiliary/libcrateresolve1-2.somelib
9+
= note: candidate #3: $TEST_BUILD_DIR/auxiliary/libcrateresolve1-3.somelib
1010

1111
error: aborting due to 1 previous error
1212

tests/ui/crate-loading/crateresolve2.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ error[E0464]: multiple candidates for `rmeta` dependency `crateresolve2` found
44
LL | extern crate crateresolve2;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: candidate #1: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-1.rmeta
8-
= note: candidate #2: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-2.rmeta
9-
= note: candidate #3: $TEST_BUILD_DIR/crate-loading/crateresolve2/auxiliary/libcrateresolve2-3.rmeta
7+
= note: candidate #1: $TEST_BUILD_DIR/auxiliary/libcrateresolve2-1.rmeta
8+
= note: candidate #2: $TEST_BUILD_DIR/auxiliary/libcrateresolve2-2.rmeta
9+
= note: candidate #3: $TEST_BUILD_DIR/auxiliary/libcrateresolve2-3.rmeta
1010

1111
error: aborting due to 1 previous error
1212

tests/ui/diagnostic-width/E0271.ascii.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0271]: type mismatch resolving `<Result<..., ()> as Future>::Error == Foo`
2-
--> $DIR/E0271.rs:20:5
2+
--> $DIR/E0271.rs:19:5
33
|
44
LL | / Box::new(
55
LL | | Ok::<_, ()>(
@@ -10,12 +10,12 @@ LL | | )
1010
| |_____^ type mismatch resolving `<Result<..., ()> as Future>::Error == Foo`
1111
|
1212
note: expected this to be `Foo`
13-
--> $DIR/E0271.rs:10:18
13+
--> $DIR/E0271.rs:9:18
1414
|
1515
LL | type Error = E;
1616
| ^
1717
= note: required for the cast from `Box<Result<..., ()>>` to `Box<...>`
18-
= note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
18+
= note: the full name for the type has been written to '$TEST_BUILD_DIR/E0271.long-type-$LONG_TYPE_HASH.txt'
1919
= note: consider using `--verbose` to print the full type name to the console
2020

2121
error: aborting due to 1 previous error

tests/ui/diagnostic-width/E0271.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ revisions: ascii unicode
22
//@[ascii] compile-flags: --diagnostic-width=40 -Zwrite-long-types-to-disk=yes
33
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode --diagnostic-width=40 -Zwrite-long-types-to-disk=yes
4-
//@ normalize-stderr: "'\$TEST_BUILD_DIR/.*\.long-type-\d+.txt'" -> "'$$TEST_BUILD_DIR/$$FILE.long-type-hash.txt'"
54
trait Future {
65
type Error;
76
}

tests/ui/diagnostic-width/E0271.unicode.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0271]: type mismatch resolving `<Result<..., ()> as Future>::Error == Foo`
2-
╭▸ $DIR/E0271.rs:20:5
2+
╭▸ $DIR/E0271.rs:19:5
33
44
LL │ ┏ Box::new(
55
LL │ ┃ Ok::<_, ()>(
@@ -10,12 +10,12 @@ LL │ ┃ )
1010
│ ┗━━━━━┛ type mismatch resolving `<Result<..., ()> as Future>::Error == Foo`
1111
╰╴
1212
note: expected this to be `Foo`
13-
╭▸ $DIR/E0271.rs:10:18
13+
╭▸ $DIR/E0271.rs:9:18
1414
1515
LL │ type Error = E;
1616
│ ━
1717
├ note: required for the cast from `Box<Result<..., ()>>` to `Box<...>`
18-
├ note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
18+
├ note: the full name for the type has been written to '$TEST_BUILD_DIR/E0271.long-type-$LONG_TYPE_HASH.txt'
1919
╰ note: consider using `--verbose` to print the full type name to the console
2020

2121
error: aborting due to 1 previous error

tests/ui/diagnostic-width/binop.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
2-
// The regex below normalizes the long type file name to make it suitable for compare-modes.
3-
//@ normalize-stderr: "'\$TEST_BUILD_DIR/.*\.long-type-\d+.txt'" -> "'$$TEST_BUILD_DIR/$$FILE.long-type-hash.txt'"
42
type A = (i32, i32, i32, i32);
53
type B = (A, A, A, A);
64
type C = (B, B, B, B);

tests/ui/diagnostic-width/binop.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error[E0369]: cannot add `(..., ..., ..., ...)` to `(..., ..., ..., ...)`
2-
--> $DIR/binop.rs:10:7
2+
--> $DIR/binop.rs:8:7
33
|
44
LL | x + x;
55
| - ^ - (..., ..., ..., ...)
66
| |
77
| (..., ..., ..., ...)
88
|
9-
= note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
9+
= note: the full name for the type has been written to '$TEST_BUILD_DIR/binop.long-type-$LONG_TYPE_HASH.txt'
1010
= note: consider using `--verbose` to print the full type name to the console
1111

1212
error[E0600]: cannot apply unary operator `!` to type `(..., ..., ..., ...)`
13-
--> $DIR/binop.rs:14:5
13+
--> $DIR/binop.rs:12:5
1414
|
1515
LL | !x;
1616
| ^^ cannot apply unary operator `!`
1717
|
18-
= note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
18+
= note: the full name for the type has been written to '$TEST_BUILD_DIR/binop.long-type-$LONG_TYPE_HASH.txt'
1919
= note: consider using `--verbose` to print the full type name to the console
2020

2121
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)