This repository was archived by the owner on May 28, 2025. It is now read-only.
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::
59
59
Some ( match lit. kind ( ) {
60
60
ast:: LiteralKind :: String ( data) => {
61
61
if data. is_raw ( ) {
62
- bridge:: LitKind :: StrRaw ( raw_delimiter_count ( data ) ?)
62
+ bridge:: LitKind :: StrRaw ( data . raw_delimiter_count ( ) ?)
63
63
} else {
64
64
bridge:: LitKind :: Str
65
65
}
66
66
}
67
67
ast:: LiteralKind :: ByteString ( data) => {
68
68
if data. is_raw ( ) {
69
- bridge:: LitKind :: ByteStrRaw ( raw_delimiter_count ( data ) ?)
69
+ bridge:: LitKind :: ByteStrRaw ( data . raw_delimiter_count ( ) ?)
70
70
} else {
71
71
bridge:: LitKind :: ByteStr
72
72
}
73
73
}
74
74
ast:: LiteralKind :: CString ( data) => {
75
75
if data. is_raw ( ) {
76
- bridge:: LitKind :: CStrRaw ( raw_delimiter_count ( data ) ?)
76
+ bridge:: LitKind :: CStrRaw ( data . raw_delimiter_count ( ) ?)
77
77
} else {
78
78
bridge:: LitKind :: CStr
79
79
}
@@ -86,13 +86,6 @@ fn literal_to_external(literal: ast::LiteralKind) -> Option<proc_macro::bridge::
86
86
} )
87
87
}
88
88
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
-
96
89
fn str_to_lit_node ( input : & str ) -> Option < ast:: Literal > {
97
90
let input = input. trim ( ) ;
98
91
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 {
204
204
assert ! ( TextRange :: up_to( contents_range. len( ) ) . contains_range( range) ) ;
205
205
Some ( range + contents_range. start ( ) )
206
206
}
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
+ }
207
217
}
208
218
209
219
impl IsString for ast:: String {
You can’t perform that action at this time.
0 commit comments