Skip to content

Commit e246109

Browse files
committed
[ui tests]: Normalize away THIR end span for output stability
Spans for the `offset_of!` builtin macro point into an arbitrary place in `core::mem`. This means that the test has to be re-blessed whenever `core/src/mem/mod.rs` line numbers change. Ideally, Span printing would be smarter and wouldn't show an end span if it came from a different crate than the start span (or maybe truncated the span to the last place in the start's crate). But that's a more involved fix and this avoids the immediate problem.
1 parent db6bc0f commit e246109

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

tests/ui/thir-print/offset_of.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ compile-flags: -Zunpretty=thir-tree --crate-type=lib
22
//@ normalize-stdout: "DefId\([^ ]* ~ (\w*)\[....\]" -> "DefId($1"
3+
//@ normalize-stdout: "DIR/offset_of.rs:(\d+:\d+): \d+:\d+ \(" -> "DIR/offset_of.rs:$1: LL:CC ("
34
//@ check-pass
45

56
#![feature(offset_of_enum)]

tests/ui/thir-print/offset_of.stdout

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ body:
55
Expr {
66
ty: ()
77
temp_scope_id: 52
8-
span: $DIR/offset_of.rs:36:19: 42:2 (#0)
8+
span: $DIR/offset_of.rs:37:19: LL:CC (#0)
99
kind:
1010
Scope {
1111
region_scope: Node(52)
@@ -14,11 +14,11 @@ body:
1414
Expr {
1515
ty: ()
1616
temp_scope_id: 52
17-
span: $DIR/offset_of.rs:36:19: 42:2 (#0)
17+
span: $DIR/offset_of.rs:37:19: LL:CC (#0)
1818
kind:
1919
Block {
2020
targeted_by_break: false
21-
span: $DIR/offset_of.rs:36:19: 42:2 (#0)
21+
span: $DIR/offset_of.rs:37:19: LL:CC (#0)
2222
region_scope: Node(1)
2323
safety_mode: Safe
2424
stmts: [
@@ -29,7 +29,7 @@ body:
2929
pattern:
3030
Pat {
3131
ty: usize
32-
span: $DIR/offset_of.rs:37:9: 37:10 (#0)
32+
span: $DIR/offset_of.rs:38:9: LL:CC (#0)
3333
kind: PatKind {
3434
Binding {
3535
name: "x"
@@ -68,7 +68,7 @@ body:
6868
)
6969
else_block: None
7070
hir_id: HirId(DefId(offset_of::concrete).10)
71-
span: $DIR/offset_of.rs:37:5: 1445:57 (#0)
71+
span: $DIR/offset_of.rs:38:5: LL:CC (#0)
7272
}
7373
}
7474
Stmt {
@@ -78,7 +78,7 @@ body:
7878
pattern:
7979
Pat {
8080
ty: usize
81-
span: $DIR/offset_of.rs:38:9: 38:10 (#0)
81+
span: $DIR/offset_of.rs:39:9: LL:CC (#0)
8282
kind: PatKind {
8383
Binding {
8484
name: "y"
@@ -117,7 +117,7 @@ body:
117117
)
118118
else_block: None
119119
hir_id: HirId(DefId(offset_of::concrete).20)
120-
span: $DIR/offset_of.rs:38:5: 1445:57 (#0)
120+
span: $DIR/offset_of.rs:39:5: LL:CC (#0)
121121
}
122122
}
123123
Stmt {
@@ -127,7 +127,7 @@ body:
127127
pattern:
128128
Pat {
129129
ty: usize
130-
span: $DIR/offset_of.rs:39:9: 39:10 (#0)
130+
span: $DIR/offset_of.rs:40:9: LL:CC (#0)
131131
kind: PatKind {
132132
Binding {
133133
name: "h"
@@ -166,7 +166,7 @@ body:
166166
)
167167
else_block: None
168168
hir_id: HirId(DefId(offset_of::concrete).30)
169-
span: $DIR/offset_of.rs:39:5: 1445:57 (#0)
169+
span: $DIR/offset_of.rs:40:5: LL:CC (#0)
170170
}
171171
}
172172
Stmt {
@@ -176,7 +176,7 @@ body:
176176
pattern:
177177
Pat {
178178
ty: usize
179-
span: $DIR/offset_of.rs:40:9: 40:11 (#0)
179+
span: $DIR/offset_of.rs:41:9: LL:CC (#0)
180180
kind: PatKind {
181181
Binding {
182182
name: "z0"
@@ -215,7 +215,7 @@ body:
215215
)
216216
else_block: None
217217
hir_id: HirId(DefId(offset_of::concrete).40)
218-
span: $DIR/offset_of.rs:40:5: 1445:57 (#0)
218+
span: $DIR/offset_of.rs:41:5: LL:CC (#0)
219219
}
220220
}
221221
Stmt {
@@ -225,7 +225,7 @@ body:
225225
pattern:
226226
Pat {
227227
ty: usize
228-
span: $DIR/offset_of.rs:41:9: 41:11 (#0)
228+
span: $DIR/offset_of.rs:42:9: LL:CC (#0)
229229
kind: PatKind {
230230
Binding {
231231
name: "z1"
@@ -264,7 +264,7 @@ body:
264264
)
265265
else_block: None
266266
hir_id: HirId(DefId(offset_of::concrete).50)
267-
span: $DIR/offset_of.rs:41:5: 1445:57 (#0)
267+
span: $DIR/offset_of.rs:42:5: LL:CC (#0)
268268
}
269269
}
270270
]
@@ -801,7 +801,7 @@ body:
801801
Expr {
802802
ty: ()
803803
temp_scope_id: 50
804-
span: $DIR/offset_of.rs:44:21: 49:2 (#0)
804+
span: $DIR/offset_of.rs:45:21: LL:CC (#0)
805805
kind:
806806
Scope {
807807
region_scope: Node(50)
@@ -810,11 +810,11 @@ body:
810810
Expr {
811811
ty: ()
812812
temp_scope_id: 50
813-
span: $DIR/offset_of.rs:44:21: 49:2 (#0)
813+
span: $DIR/offset_of.rs:45:21: LL:CC (#0)
814814
kind:
815815
Block {
816816
targeted_by_break: false
817-
span: $DIR/offset_of.rs:44:21: 49:2 (#0)
817+
span: $DIR/offset_of.rs:45:21: LL:CC (#0)
818818
region_scope: Node(1)
819819
safety_mode: Safe
820820
stmts: [
@@ -825,7 +825,7 @@ body:
825825
pattern:
826826
Pat {
827827
ty: usize
828-
span: $DIR/offset_of.rs:45:9: 45:11 (#0)
828+
span: $DIR/offset_of.rs:46:9: LL:CC (#0)
829829
kind: PatKind {
830830
Binding {
831831
name: "gx"
@@ -864,7 +864,7 @@ body:
864864
)
865865
else_block: None
866866
hir_id: HirId(DefId(offset_of::generic).12)
867-
span: $DIR/offset_of.rs:45:5: 1445:57 (#0)
867+
span: $DIR/offset_of.rs:46:5: LL:CC (#0)
868868
}
869869
}
870870
Stmt {
@@ -874,7 +874,7 @@ body:
874874
pattern:
875875
Pat {
876876
ty: usize
877-
span: $DIR/offset_of.rs:46:9: 46:11 (#0)
877+
span: $DIR/offset_of.rs:47:9: LL:CC (#0)
878878
kind: PatKind {
879879
Binding {
880880
name: "gy"
@@ -913,7 +913,7 @@ body:
913913
)
914914
else_block: None
915915
hir_id: HirId(DefId(offset_of::generic).24)
916-
span: $DIR/offset_of.rs:46:5: 1445:57 (#0)
916+
span: $DIR/offset_of.rs:47:5: LL:CC (#0)
917917
}
918918
}
919919
Stmt {
@@ -923,7 +923,7 @@ body:
923923
pattern:
924924
Pat {
925925
ty: usize
926-
span: $DIR/offset_of.rs:47:9: 47:11 (#0)
926+
span: $DIR/offset_of.rs:48:9: LL:CC (#0)
927927
kind: PatKind {
928928
Binding {
929929
name: "dx"
@@ -962,7 +962,7 @@ body:
962962
)
963963
else_block: None
964964
hir_id: HirId(DefId(offset_of::generic).36)
965-
span: $DIR/offset_of.rs:47:5: 1445:57 (#0)
965+
span: $DIR/offset_of.rs:48:5: LL:CC (#0)
966966
}
967967
}
968968
Stmt {
@@ -972,7 +972,7 @@ body:
972972
pattern:
973973
Pat {
974974
ty: usize
975-
span: $DIR/offset_of.rs:48:9: 48:11 (#0)
975+
span: $DIR/offset_of.rs:49:9: LL:CC (#0)
976976
kind: PatKind {
977977
Binding {
978978
name: "dy"
@@ -1011,7 +1011,7 @@ body:
10111011
)
10121012
else_block: None
10131013
hir_id: HirId(DefId(offset_of::generic).48)
1014-
span: $DIR/offset_of.rs:48:5: 1445:57 (#0)
1014+
span: $DIR/offset_of.rs:49:5: LL:CC (#0)
10151015
}
10161016
}
10171017
]

0 commit comments

Comments
 (0)