File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -59,21 +59,21 @@ fn literal_to_external(literal: ast::LiteralKind) -> Option<proc_macro::bridge::
5959 Some ( match lit. kind ( ) {
6060 ast:: LiteralKind :: String ( data) => {
6161 if data. is_raw ( ) {
62- bridge:: LitKind :: StrRaw ( raw_delimiter_count ( data ) ?)
62+ bridge:: LitKind :: StrRaw ( data . raw_delimiter_count ( ) ?)
6363 } else {
6464 bridge:: LitKind :: Str
6565 }
6666 }
6767 ast:: LiteralKind :: ByteString ( data) => {
6868 if data. is_raw ( ) {
69- bridge:: LitKind :: ByteStrRaw ( raw_delimiter_count ( data ) ?)
69+ bridge:: LitKind :: ByteStrRaw ( data . raw_delimiter_count ( ) ?)
7070 } else {
7171 bridge:: LitKind :: ByteStr
7272 }
7373 }
7474 ast:: LiteralKind :: CString ( data) => {
7575 if data. is_raw ( ) {
76- bridge:: LitKind :: CStrRaw ( raw_delimiter_count ( data ) ?)
76+ bridge:: LitKind :: CStrRaw ( data . raw_delimiter_count ( ) ?)
7777 } else {
7878 bridge:: LitKind :: CStr
7979 }
@@ -86,13 +86,6 @@ fn literal_to_external(literal: ast::LiteralKind) -> Option<proc_macro::bridge::
8686 } )
8787}
8888
89- fn raw_delimiter_count < S : IsString > ( s : S ) -> Option < u8 > {
90- let text = s. text ( ) ;
91- let quote_range = s. text_range_between_quotes ( ) ?;
92- let range_start = s. syntax ( ) . text_range ( ) . start ( ) ;
93- text[ TextRange :: up_to ( ( quote_range - range_start) . start ( ) ) ] . matches ( '#' ) . count ( ) . try_into ( ) . ok ( )
94- }
95-
9689fn str_to_lit_node ( input : & str ) -> Option < ast:: Literal > {
9790 let input = input. trim ( ) ;
9891 let source_code = format ! ( "fn f() {{ let _ = {input}; }}" ) ;
Original file line number Diff line number Diff line change @@ -204,6 +204,16 @@ pub trait IsString: AstToken {
204204 assert ! ( TextRange :: up_to( contents_range. len( ) ) . contains_range( range) ) ;
205205 Some ( range + contents_range. start ( ) )
206206 }
207+ fn raw_delimiter_count ( & self ) -> Option < u8 > {
208+ let text = self . text ( ) ;
209+ let quote_range = self . text_range_between_quotes ( ) ?;
210+ let range_start = self . syntax ( ) . text_range ( ) . start ( ) ;
211+ text[ TextRange :: up_to ( ( quote_range - range_start) . start ( ) ) ]
212+ . matches ( '#' )
213+ . count ( )
214+ . try_into ( )
215+ . ok ( )
216+ }
207217}
208218
209219impl IsString for ast:: String {
You can’t perform that action at this time.
0 commit comments