@@ -159,14 +159,14 @@ impl Attrs {
159159 pub fn has_doc_hidden ( & self ) -> bool {
160160 self . by_key ( "doc" ) . tt_values ( ) . any ( |tt| {
161161 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)
163163 } )
164164 }
165165
166166 pub fn has_doc_notable_trait ( & self ) -> bool {
167167 self . by_key ( "doc" ) . tt_values ( ) . any ( |tt| {
168168 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)
170170 } )
171171 }
172172
@@ -267,21 +267,24 @@ impl DocExpr {
267267fn next_doc_expr < S > ( it : & mut SliceIter < ' _ , tt:: TokenTree < S > > ) -> Option < DocExpr > {
268268 let name = match it. next ( ) {
269269 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 ( ) ,
271271 Some ( _) => return Some ( DocExpr :: Invalid ) ,
272272 } ;
273273
274274 // Peek
275275 let ret = match it. as_slice ( ) . first ( ) {
276276 Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( punct) ) ) if punct. char == '=' => {
277277 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+ } ) ) ) => {
279283 it. next ( ) ;
280284 it. next ( ) ;
281285 // 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 ( )
285288 }
286289 _ => return Some ( DocExpr :: Invalid ) ,
287290 }
@@ -294,7 +297,7 @@ fn next_doc_expr<S>(it: &mut SliceIter<'_, tt::TokenTree<S>>) -> Option<DocExpr>
294297 _ => DocExpr :: Invalid ,
295298 }
296299 }
297- _ => DocAtom :: Flag ( name) . into ( ) ,
300+ _ => DocAtom :: Flag ( name. as_str ( ) . into ( ) ) . into ( ) ,
298301 } ;
299302
300303 // Eat comma separator
@@ -311,10 +314,11 @@ fn parse_comma_sep<S>(subtree: &tt::Subtree<S>) -> Vec<SmolStr> {
311314 . token_trees
312315 . iter ( )
313316 . 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 ( ) ) ) ,
318322 _ => None ,
319323 } )
320324 . collect ( )
@@ -598,14 +602,14 @@ impl<'attr> AttrQuery<'attr> {
598602 /// #[doc(html_root_url = "url")]
599603 /// ^^^^^^^^^^^^^ key
600604 /// ```
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 > {
602606 self . tt_values ( ) . find_map ( |tt| {
603607 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) )
605609 . nth ( 2 ) ;
606610
607611 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 ( ) ) ,
609613 _ => None
610614 }
611615 } )
0 commit comments