about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2016-10-15 02:56:29 +0200
committerJonas Schievink <jonas@schievink.net>2016-11-09 14:55:39 +0100
commitfb7a8294f898652482e4b4106143fac294d7af0d (patch)
treefbeff84adfc170555e33c164d61cc529aed52a04
parent966c70085adc69eecf9c8cd1f128872e8d90614d (diff)
downloadrust-fb7a8294f898652482e4b4106143fac294d7af0d.tar.gz
rust-fb7a8294f898652482e4b4106143fac294d7af0d.zip
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.
-rw-r--r--src/libproc_macro_tokens/parse.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libproc_macro_tokens/parse.rs b/src/libproc_macro_tokens/parse.rs
index 9af8a68cdcf..5ab4fcd5dab 100644
--- a/src/libproc_macro_tokens/parse.rs
+++ b/src/libproc_macro_tokens/parse.rs
@@ -15,12 +15,12 @@ extern crate syntax;
 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())))
 }