@@ -159,14 +159,14 @@ impl Attrs {
159
159
pub fn has_doc_hidden ( & self ) -> bool {
160
160
self . by_key ( "doc" ) . tt_values ( ) . any ( |tt| {
161
161
tt. delimiter . kind == DelimiterKind :: Parenthesis &&
162
- matches ! ( & * tt. token_trees, [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] if ident. text == " hidden" )
162
+ matches ! ( & * tt. token_trees, [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] if ident. sym == sym :: hidden)
163
163
} )
164
164
}
165
165
166
166
pub fn has_doc_notable_trait ( & self ) -> bool {
167
167
self . by_key ( "doc" ) . tt_values ( ) . any ( |tt| {
168
168
tt. delimiter . kind == DelimiterKind :: Parenthesis &&
169
- matches ! ( & * tt. token_trees, [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] if ident. text == " notable_trait" )
169
+ matches ! ( & * tt. token_trees, [ tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ] if ident. sym == sym :: notable_trait)
170
170
} )
171
171
}
172
172
@@ -267,21 +267,24 @@ impl DocExpr {
267
267
fn next_doc_expr < S > ( it : & mut SliceIter < ' _ , tt:: TokenTree < S > > ) -> Option < DocExpr > {
268
268
let name = match it. next ( ) {
269
269
None => return None ,
270
- Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ) => ident. text . clone ( ) ,
270
+ Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) ) => ident. sym . clone ( ) ,
271
271
Some ( _) => return Some ( DocExpr :: Invalid ) ,
272
272
} ;
273
273
274
274
// Peek
275
275
let ret = match it. as_slice ( ) . first ( ) {
276
276
Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( punct) ) ) if punct. char == '=' => {
277
277
match it. as_slice ( ) . get ( 1 ) {
278
- Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( literal) ) ) => {
278
+ Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
279
+ symbol : text,
280
+ kind : tt:: LitKind :: Str ,
281
+ ..
282
+ } ) ) ) => {
279
283
it. next ( ) ;
280
284
it. next ( ) ;
281
285
// FIXME: escape? raw string?
282
- let value =
283
- SmolStr :: new ( literal. text . trim_start_matches ( '"' ) . trim_end_matches ( '"' ) ) ;
284
- DocAtom :: KeyValue { key : name, value } . into ( )
286
+ let value = SmolStr :: new ( text. as_str ( ) ) ;
287
+ DocAtom :: KeyValue { key : name. as_str ( ) . into ( ) , value } . into ( )
285
288
}
286
289
_ => return Some ( DocExpr :: Invalid ) ,
287
290
}
@@ -294,7 +297,7 @@ fn next_doc_expr<S>(it: &mut SliceIter<'_, tt::TokenTree<S>>) -> Option<DocExpr>
294
297
_ => DocExpr :: Invalid ,
295
298
}
296
299
}
297
- _ => DocAtom :: Flag ( name) . into ( ) ,
300
+ _ => DocAtom :: Flag ( name. as_str ( ) . into ( ) ) . into ( ) ,
298
301
} ;
299
302
300
303
// Eat comma separator
@@ -311,10 +314,11 @@ fn parse_comma_sep<S>(subtree: &tt::Subtree<S>) -> Vec<SmolStr> {
311
314
. token_trees
312
315
. iter ( )
313
316
. filter_map ( |tt| match tt {
314
- tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( lit) ) => {
315
- // FIXME: escape? raw string?
316
- Some ( SmolStr :: new ( lit. text . trim_start_matches ( '"' ) . trim_end_matches ( '"' ) ) )
317
- }
317
+ tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
318
+ kind : tt:: LitKind :: Str ,
319
+ symbol : text,
320
+ ..
321
+ } ) ) => Some ( SmolStr :: new ( text. as_str ( ) ) ) ,
318
322
_ => None ,
319
323
} )
320
324
. collect ( )
@@ -598,14 +602,14 @@ impl<'attr> AttrQuery<'attr> {
598
602
/// #[doc(html_root_url = "url")]
599
603
/// ^^^^^^^^^^^^^ key
600
604
/// ```
601
- pub fn find_string_value_in_tt ( self , key : & ' attr str ) -> Option < & SmolStr > {
605
+ pub fn find_string_value_in_tt ( self , key : & ' attr str ) -> Option < & str > {
602
606
self . tt_values ( ) . find_map ( |tt| {
603
607
let name = tt. token_trees . iter ( )
604
- . skip_while ( |tt| !matches ! ( tt, tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( tt:: Ident { text , ..} ) ) if text == key) )
608
+ . skip_while ( |tt| !matches ! ( tt, tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( tt:: Ident { sym , ..} ) ) if sym . as_str ( ) == key) )
605
609
. nth ( 2 ) ;
606
610
607
611
match name {
608
- Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal { text, kind : tt:: LitKind :: Str | tt:: LitKind :: StrRaw ( _) , ..} ) ) ) => Some ( text) ,
612
+ Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal { symbol : text, kind : tt:: LitKind :: Str | tt:: LitKind :: StrRaw ( _) , ..} ) ) ) => Some ( text. as_str ( ) ) ,
609
613
_ => None
610
614
}
611
615
} )
0 commit comments