Skip to content

Commit 6e24868

Browse files
committed
Normalize source line and column numbers.
This commit adds a normalization for line and column numbers in stderr files where the line/col is from the source directory rather than the test itself - thereby removing the need to update tests as compiler source changes.
1 parent 70c33bb commit 6e24868

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Diff for: src/test/ui/consts/const-size_of-cycle.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0391]: cycle detected when computing layout of `Foo`
22
|
33
note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`...
44
note: ...which requires const-evaluating `Foo::bytes::{{constant}}`...
5-
--> $SRC_DIR/libcore/mem.rs:323:14
5+
--> $SRC_DIR/libcore/mem.rs:LL:COL
66
|
77
LL | unsafe { intrinsics::size_of::<T>() }
88
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
99
= note: ...which again requires computing layout of `Foo`, completing the cycle
1010
note: cycle used when const-evaluating `Foo::bytes::{{constant}}`
11-
--> $SRC_DIR/libcore/mem.rs:323:14
11+
--> $SRC_DIR/libcore/mem.rs:LL:COL
1212
|
1313
LL | unsafe { intrinsics::size_of::<T>() }
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

Diff for: src/test/ui/impl-trait/impl-generic-mismatch.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ error[E0643]: method `hash` has incompatible signature for trait
3030
LL | fn hash(&self, hasher: &mut impl Hasher) {}
3131
| ^^^^^^^^^^^ expected generic parameter, found `impl Trait`
3232
|
33-
::: $SRC_DIR/libcore/hash/mod.rs:185:13
33+
::: $SRC_DIR/libcore/hash/mod.rs:LL:COL
3434
|
3535
LL | fn hash<H: Hasher>(&self, state: &mut H);
3636
| - declaration in trait here

Diff for: src/tools/compiletest/src/runtest.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2963,6 +2963,13 @@ impl<'test> TestCx<'test> {
29632963
normalized = normalized.replace("\\n", "\n");
29642964
}
29652965

2966+
// If there are `$SRC_DIR` normalizations with line and column numbers, then replace them
2967+
// with placeholders as we do not want tests needing updated when compiler source code
2968+
// changes.
2969+
// eg. $SRC_DIR/libcore/mem.rs:323:14 becomes $SRC_DIR/libcore/mem.rs:LL:COL
2970+
normalized = Regex::new("SRC_DIR(.+):\\d+:\\d+").unwrap()
2971+
.replace_all(&normalized, "SRC_DIR$1:LL:COL").into_owned();
2972+
29662973
normalized = normalized.replace("\\\\", "\\") // denormalize for paths on windows
29672974
.replace("\\", "/") // normalize for paths on windows
29682975
.replace("\r\n", "\n") // normalize for linebreaks on windows

0 commit comments

Comments
 (0)