@@ -57,7 +57,13 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
57
57
58
58
/// `Ok` represents successfully retrieving the string literal at the correct
59
59
/// position, e.g., `println("abc")`.
60
- type ExprToSpannedStringResult < ' a > = Result < ( Symbol , ast:: StrStyle , Span ) , UnexpectedExprKind < ' a > > ;
60
+ pub ( crate ) type ExprToSpannedStringResult < ' a > = Result < ExprToSpannedString , UnexpectedExprKind < ' a > > ;
61
+
62
+ pub ( crate ) struct ExprToSpannedString {
63
+ pub symbol : Symbol ,
64
+ pub style : ast:: StrStyle ,
65
+ pub span : Span ,
66
+ }
61
67
62
68
/// - `Ok` is returned when the conversion to a string literal is unsuccessful,
63
69
/// but another type of expression is obtained instead.
@@ -90,7 +96,11 @@ pub(crate) fn expr_to_spanned_string<'a>(
90
96
ExpandResult :: Ready ( Err ( match expr. kind {
91
97
ast:: ExprKind :: Lit ( token_lit) => match ast:: LitKind :: from_token_lit ( token_lit) {
92
98
Ok ( ast:: LitKind :: Str ( s, style) ) => {
93
- return ExpandResult :: Ready ( Ok ( ( s, style, expr. span ) ) ) ;
99
+ return ExpandResult :: Ready ( Ok ( ExprToSpannedString {
100
+ symbol : s,
101
+ style,
102
+ span : expr. span ,
103
+ } ) ) ;
94
104
}
95
105
Ok ( ast:: LitKind :: ByteStr ( ..) ) => {
96
106
let mut err = cx. dcx ( ) . struct_span_err ( expr. span , err_msg) ;
@@ -128,7 +138,7 @@ pub(crate) fn expr_to_string(
128
138
Ok ( ( err, _) ) => err. emit ( ) ,
129
139
Err ( guar) => guar,
130
140
} )
131
- . map ( |( symbol, style, _ ) | ( symbol, style) )
141
+ . map ( |ExprToSpannedString { symbol, style, .. } | ( symbol, style) )
132
142
} )
133
143
}
134
144
@@ -183,7 +193,7 @@ pub(crate) fn get_single_str_spanned_from_tts(
183
193
Ok ( ( err, _) ) => err. emit ( ) ,
184
194
Err ( guar) => guar,
185
195
} )
186
- . map ( |( symbol, _style , span ) | ( symbol, span) )
196
+ . map ( |ExprToSpannedString { symbol, span , .. } | ( symbol, span) )
187
197
} )
188
198
}
189
199
0 commit comments