Skip to content

Commit 332fd4d

Browse files
committed
Avoid cargo always re-compiling crates that use the syntax extension
The filename passed to new_parser_from_source_str gets added to the codemap, which is used to generate the dep-info list, so cargo thought the crate depended on a non-existent file called "peg". The dep-info output ignores filenames surrounded by "<>". It should probably instead somehow use the crate map entry for the .rustpeg file, but that can wait for the new plugin API, if it applies there.
1 parent 1cbe59a commit 332fd4d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/rustast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn module(items: Vec<P<Item>>) -> P<Mod> {
1717
}
1818

1919
pub fn parse_path(ctxt: &ExtCtxt, e: &str) -> ast::Path {
20-
let mut p = syntax::parse::new_parser_from_source_str(&ctxt.parse_sess, Vec::new(), "peg".to_string(), e.to_string());
20+
let mut p = syntax::parse::new_parser_from_source_str(&ctxt.parse_sess, Vec::new(), "<peg>".to_string(), e.to_string());
2121
let r = panictry!(p.parse_path(syntax::parse::parser::NoTypesAllowed));
2222
p.abort_if_errors();
2323
r
@@ -28,14 +28,14 @@ pub fn parse_path_vec(s: &str) -> Vec<ast::Ident> {
2828
}
2929

3030
pub fn parse_block(ctxt: &ExtCtxt, e: &str) -> P<ast::Block> {
31-
let mut p = syntax::parse::new_parser_from_source_str(&ctxt.parse_sess, Vec::new(), "peg".to_string(), e.to_string());
31+
let mut p = syntax::parse::new_parser_from_source_str(&ctxt.parse_sess, Vec::new(), "<peg>".to_string(), e.to_string());
3232
let r = panictry!(p.parse_block());
3333
p.abort_if_errors();
3434
r
3535
}
3636

3737
pub fn parse_type(ctxt: &ExtCtxt, e: &str) -> P<ast::Ty> {
38-
let mut p = syntax::parse::new_parser_from_source_str(&ctxt.parse_sess, Vec::new(), "peg".to_string(), e.to_string());
38+
let mut p = syntax::parse::new_parser_from_source_str(&ctxt.parse_sess, Vec::new(), "<peg>".to_string(), e.to_string());
3939
let r = panictry!(p.parse_ty());
4040
p.abort_if_errors();
4141
r

0 commit comments

Comments
 (0)