@@ -13,7 +13,7 @@ fn adapt_pattern(pattern: &mut ast::Pattern<String>, crlf: bool) {
13
13
let mut elements = vec ! [ ] ;
14
14
for element in & pattern. elements {
15
15
match element {
16
- ast:: PatternElement :: TextElement { value } => {
16
+ ast:: PatternElement :: TextElement { value, .. } => {
17
17
let mut start = 0 ;
18
18
let len = value. len ( ) ;
19
19
for ( i, b) in value. as_bytes ( ) . iter ( ) . enumerate ( ) {
@@ -22,29 +22,53 @@ fn adapt_pattern(pattern: &mut ast::Pattern<String>, crlf: bool) {
22
22
if i > start {
23
23
let chunk = & value. as_bytes ( ) [ start..=i - 1 ] ;
24
24
let value = String :: from_utf8_lossy ( chunk) . to_string ( ) ;
25
- elements. push ( ast:: PatternElement :: TextElement { value } ) ;
25
+ elements. push ( ast:: PatternElement :: TextElement {
26
+ value,
27
+ #[ cfg( feature = "spans" ) ]
28
+ span : ast:: Span ( start..i) ,
29
+ } ) ;
26
30
}
31
+
27
32
elements. push ( ast:: PatternElement :: TextElement {
28
33
value : "\n " . to_string ( ) ,
34
+ #[ cfg( feature = "spans" ) ]
35
+ span : ast:: Span ( i..i + 1 ) ,
29
36
} ) ;
30
37
} else {
31
38
let chunk = & value. as_bytes ( ) [ start..=i] ;
32
39
let value = String :: from_utf8_lossy ( chunk) . to_string ( ) ;
33
- elements. push ( ast:: PatternElement :: TextElement { value } ) ;
40
+ elements. push ( ast:: PatternElement :: TextElement {
41
+ value,
42
+ #[ cfg( feature = "spans" ) ]
43
+ span : ast:: Span ( start..i + 1 ) ,
44
+ } ) ;
34
45
}
35
46
start = i + 1 ;
36
47
}
37
48
}
49
+
38
50
if start < len {
39
51
let chunk = & value. as_bytes ( ) [ start..len] ;
40
52
let value = String :: from_utf8_lossy ( chunk) . to_string ( ) ;
41
- elements. push ( ast:: PatternElement :: TextElement { value } ) ;
53
+ elements. push ( ast:: PatternElement :: TextElement {
54
+ value,
55
+ #[ cfg( feature = "spans" ) ]
56
+ span : ast:: Span ( start..len) ,
57
+ } ) ;
42
58
}
43
59
}
44
- ast:: PatternElement :: Placeable { expression } => {
60
+ ast:: PatternElement :: Placeable {
61
+ expression,
62
+ #[ cfg( feature = "spans" ) ]
63
+ span,
64
+ } => {
45
65
let mut expression = expression. clone ( ) ;
46
66
adapt_expression ( & mut expression, crlf) ;
47
- elements. push ( ast:: PatternElement :: Placeable { expression } ) ;
67
+ elements. push ( ast:: PatternElement :: Placeable {
68
+ expression,
69
+ #[ cfg( feature = "spans" ) ]
70
+ span : span. clone ( ) ,
71
+ } ) ;
48
72
}
49
73
}
50
74
}
@@ -58,7 +82,7 @@ fn adapt_expression(expression: &mut ast::Expression<String>, crlf: bool) {
58
82
adapt_pattern ( & mut variant. value , crlf) ;
59
83
}
60
84
}
61
- ast:: Expression :: Inline ( _ ) => { }
85
+ ast:: Expression :: Inline ( .. ) => { }
62
86
}
63
87
}
64
88
0 commit comments