@@ -57,7 +57,13 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
5757
5858/// `Ok` represents successfully retrieving the string literal at the correct
5959/// 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+ }
6167
6268/// - `Ok` is returned when the conversion to a string literal is unsuccessful,
6369/// but another type of expression is obtained instead.
@@ -90,7 +96,11 @@ pub(crate) fn expr_to_spanned_string<'a>(
9096 ExpandResult :: Ready ( Err ( match expr. kind {
9197 ast:: ExprKind :: Lit ( token_lit) => match ast:: LitKind :: from_token_lit ( token_lit) {
9298 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+ } ) ) ;
94104 }
95105 Ok ( ast:: LitKind :: ByteStr ( ..) ) => {
96106 let mut err = cx. dcx ( ) . struct_span_err ( expr. span , err_msg) ;
@@ -128,7 +138,7 @@ pub(crate) fn expr_to_string(
128138 Ok ( ( err, _) ) => err. emit ( ) ,
129139 Err ( guar) => guar,
130140 } )
131- . map ( |( symbol, style, _ ) | ( symbol, style) )
141+ . map ( |ExprToSpannedString { symbol, style, .. } | ( symbol, style) )
132142 } )
133143}
134144
@@ -183,7 +193,7 @@ pub(crate) fn get_single_str_spanned_from_tts(
183193 Ok ( ( err, _) ) => err. emit ( ) ,
184194 Err ( guar) => guar,
185195 } )
186- . map ( |( symbol, _style , span ) | ( symbol, span) )
196+ . map ( |ExprToSpannedString { symbol, span , .. } | ( symbol, span) )
187197 } )
188198}
189199
0 commit comments