diff --git a/peg-macros/translate.rs b/peg-macros/translate.rs index 166f18f..01ecc04 100644 --- a/peg-macros/translate.rs +++ b/peg-macros/translate.rs @@ -347,7 +347,7 @@ fn compile_rule_export(context: &Context, rule: &Rule) -> TokenStream { .. } = rule; let ret_ty = rule.ret_type.clone().unwrap_or_else(|| quote!(())); - let parse_fn = format_ident!("__parse_{}", rule.name.to_string(), span = name.span()); + let parse_fn = format_ident!("__parse_{}", rule.name, span = name.span()); let ty_params = ty_params_slice(&rule.ty_params); let where_clause = rule.where_clause.as_ref().into_iter(); let rule_params = rule_params_list(context, rule); diff --git a/tests/run-pass/raw_ident.rs b/tests/run-pass/raw_ident.rs new file mode 100644 index 0000000..bb38158 --- /dev/null +++ b/tests/run-pass/raw_ident.rs @@ -0,0 +1,12 @@ +extern crate peg; +use peg::parser; + +parser!{ + pub grammar g() for str { + pub rule r#break() = "foo" + } +} + +fn main() { + assert_eq!(g::r#break("foo"), Ok(())); +}