Skip to content

Commit fb7a829

Browse files
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@332fd4d. 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.
1 parent 966c700 commit fb7a829

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libproc_macro_tokens/parse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ extern crate syntax;
1515
use syntax::parse::{ParseSess, filemap_to_tts};
1616
use syntax::tokenstream::TokenStream;
1717

18-
/// Map a string to tts, using a made-up filename. For example, `lex(15)` will return a
18+
/// Map a string to tts, using a made-up filename. For example, `lex("15")` will return a
1919
/// TokenStream containing the literal 15.
2020
pub fn lex(source_str: &str) -> TokenStream {
2121
let ps = ParseSess::new();
2222
TokenStream::from_tts(filemap_to_tts(&ps,
23-
ps.codemap().new_filemap("procmacro_lex".to_string(),
23+
ps.codemap().new_filemap("<procmacro_lex>".to_string(),
2424
None,
2525
source_str.to_owned())))
2626
}

0 commit comments

Comments
 (0)