Skip to content

Commit 8aa2de0

Browse files
authored
Merge pull request #379 from A4-Tacks/fix-raw_ident_format_failed
Fix raw ident format to invalid ident (#378)
2 parents d888952 + e5c473a commit 8aa2de0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

peg-macros/translate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fn compile_rule_export(context: &Context, rule: &Rule) -> TokenStream {
347347
..
348348
} = rule;
349349
let ret_ty = rule.ret_type.clone().unwrap_or_else(|| quote!(()));
350-
let parse_fn = format_ident!("__parse_{}", rule.name.to_string(), span = name.span());
350+
let parse_fn = format_ident!("__parse_{}", rule.name, span = name.span());
351351
let ty_params = ty_params_slice(&rule.ty_params);
352352
let where_clause = rule.where_clause.as_ref().into_iter();
353353
let rule_params = rule_params_list(context, rule);

tests/run-pass/raw_ident.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extern crate peg;
2+
use peg::parser;
3+
4+
parser!{
5+
pub grammar g() for str {
6+
pub rule r#break() = "foo"
7+
}
8+
}
9+
10+
fn main() {
11+
assert_eq!(g::r#break("foo"), Ok(()));
12+
}

0 commit comments

Comments
 (0)