Repository: kevinmehall/rust-peg (language: rust)

Issue:
Raw identify resolv failed
```rust
peg::parser!(grammar parser() for str {
    pub rule r#break() =
});
```

```
error: proc macro panicked
 --> src/parser.rs:1:1
  |
1 | / peg::parser!(grammar parser() for str {
2 | |     pub rule r#break() =
3 | | });
  | |__^
  |
  = help: message: `"__parse_r#break"` is not a valid identifier
```


Discussion / hints:

Fix patch:
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);


Test patch:
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(()));
+}