Skip to content

Commit

Permalink
proc_macro_plugin: Wrap nonexistent filename in <>
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonas-schievink committed Nov 9, 2016
1 parent 966c700 commit fb7a829
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libproc_macro_tokens/parse.rs
Expand Up @@ -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())))
}

0 comments on commit fb7a829

Please sign in to comment.