@@ -15,8 +15,8 @@ use proc_macro::bridge::{self, server};
15
15
use span:: { Span , FIXUP_ERASED_FILE_AST_ID_MARKER } ;
16
16
17
17
use crate :: server:: {
18
- delim_to_external, delim_to_internal, token_stream :: TokenStreamBuilder , LiteralFormatter ,
19
- Symbol , SymbolInternerRef , SYMBOL_INTERNER ,
18
+ delim_to_external, delim_to_internal, literal_with_stringify_parts ,
19
+ token_stream :: TokenStreamBuilder , Symbol , SymbolInternerRef , SYMBOL_INTERNER ,
20
20
} ;
21
21
mod tt {
22
22
pub use :: tt:: * ;
@@ -180,12 +180,11 @@ impl server::TokenStream for RaSpanServer {
180
180
}
181
181
182
182
bridge:: TokenTree :: Literal ( literal) => {
183
- let literal = LiteralFormatter ( literal) ;
184
- let text = literal. with_stringify_parts ( self . interner , |parts| {
183
+ let text = literal_with_stringify_parts ( & literal, self . interner , |parts| {
185
184
:: tt:: SmolStr :: from_iter ( parts. iter ( ) . copied ( ) )
186
185
} ) ;
187
186
188
- let literal = tt:: Literal { text, span : literal. 0 . span } ;
187
+ let literal = tt:: Literal { text, span : literal. span } ;
189
188
let leaf: tt:: Leaf = tt:: Leaf :: from ( literal) ;
190
189
let tree = tt:: TokenTree :: from ( leaf) ;
191
190
Self :: TokenStream :: from_iter ( iter:: once ( tree) )
@@ -251,10 +250,17 @@ impl server::TokenStream for RaSpanServer {
251
250
. into_iter ( )
252
251
. map ( |tree| match tree {
253
252
tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( ident) ) => {
254
- bridge:: TokenTree :: Ident ( bridge:: Ident {
255
- sym : Symbol :: intern ( self . interner , ident. text . trim_start_matches ( "r#" ) ) ,
256
- is_raw : ident. text . starts_with ( "r#" ) ,
257
- span : ident. span ,
253
+ bridge:: TokenTree :: Ident ( match ident. text . strip_prefix ( "r#" ) {
254
+ Some ( text) => bridge:: Ident {
255
+ sym : Symbol :: intern ( self . interner , text) ,
256
+ is_raw : true ,
257
+ span : ident. span ,
258
+ } ,
259
+ None => bridge:: Ident {
260
+ sym : Symbol :: intern ( self . interner , & ident. text ) ,
261
+ is_raw : false ,
262
+ span : ident. span ,
263
+ } ,
258
264
} )
259
265
}
260
266
tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( lit) ) => {
@@ -285,11 +291,12 @@ impl server::TokenStream for RaSpanServer {
285
291
}
286
292
287
293
impl server:: SourceFile for RaSpanServer {
288
- // FIXME these are all stubs
289
294
fn eq ( & mut self , _file1 : & Self :: SourceFile , _file2 : & Self :: SourceFile ) -> bool {
295
+ // FIXME
290
296
true
291
297
}
292
298
fn path ( & mut self , _file : & Self :: SourceFile ) -> String {
299
+ // FIXME
293
300
String :: new ( )
294
301
}
295
302
fn is_real ( & mut self , _file : & Self :: SourceFile ) -> bool {
@@ -306,11 +313,15 @@ impl server::Span for RaSpanServer {
306
313
SourceFile { }
307
314
}
308
315
fn save_span ( & mut self , _span : Self :: Span ) -> usize {
309
- // FIXME stub, requires builtin quote! implementation
316
+ // FIXME, quote is incompatible with third-party tools
317
+ // This is called by the quote proc-macro which is expanded when the proc-macro is compiled
318
+ // As such, r-a will never observe this
310
319
0
311
320
}
312
321
fn recover_proc_macro_span ( & mut self , _id : usize ) -> Self :: Span {
313
- // FIXME stub, requires builtin quote! implementation
322
+ // FIXME, quote is incompatible with third-party tools
323
+ // This is called by the expansion of quote!, r-a will observe this, but we don't have
324
+ // access to the spans that were encoded
314
325
self . call_site
315
326
}
316
327
/// Recent feature, not yet in the proc_macro
0 commit comments