]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #37186 - jonas-schievink:patch-1, r=brson
authorbors <bors@rust-lang.org>
Thu, 10 Nov 2016 22:28:03 +0000 (14:28 -0800)
committerGitHub <noreply@github.com>
Thu, 10 Nov 2016 22:28:03 +0000 (14:28 -0800)
proc_macro_plugin: Wrap nonexistent filename in <>

I'm not sure how big of an issue this can become in practice, but `FileMap`s made from something that's not a file are supposed to wrap the file name in `<>`.

For an example fix, see kevinmehall/rust-peg@332fd4dbae19b64fb2af4b9d565e37a3703e7576. There, it caused cargo to always recompile a crate using rust-peg, even when nothing was changed, because cargo sees that the dummy file doesn't exist.

src/libproc_macro_tokens/parse.rs

index 9af8a68cdcf497887b75e09a94f5917215d33bee..5ab4fcd5dab29a74648bc3627f5a90f47717b978 100644 (file)
 use syntax::parse::{ParseSess, filemap_to_tts};
 use syntax::tokenstream::TokenStream;
 
-/// Map a string to tts, using a made-up filename. For example, `lex(15)` will return a
+/// Map a string to tts, using a made-up filename. For example, `lex("15")` will return a
 /// TokenStream containing the literal 15.
 pub fn lex(source_str: &str) -> TokenStream {
     let ps = ParseSess::new();
     TokenStream::from_tts(filemap_to_tts(&ps,
-                                         ps.codemap().new_filemap("procmacro_lex".to_string(),
+                                         ps.codemap().new_filemap("<procmacro_lex>".to_string(),
                                                                   None,
                                                                   source_str.to_owned())))
 }