summaryrefslogtreecommitdiff
path: root/dhall_syntax/src
diff options
context:
space:
mode:
authorNadrieril2019-09-02 18:46:53 +0200
committerNadrieril2019-09-02 18:46:53 +0200
commit41f598a75de41665dd9ec0aad56b5ef526698151 (patch)
tree7ffcef71c5d868066bb1a60bfc0d74852b44b68b /dhall_syntax/src
parent49f142e3cd173549b8d63883380b5e780c9fefb1 (diff)
Use proper hygiene for `Parsers` and `Rule`
Diffstat (limited to 'dhall_syntax/src')
-rw-r--r--dhall_syntax/src/lib.rs1
-rw-r--r--dhall_syntax/src/parser.rs9
2 files changed, 8 insertions, 2 deletions
diff --git a/dhall_syntax/src/lib.rs b/dhall_syntax/src/lib.rs
index fb12af4..1636c8b 100644
--- a/dhall_syntax/src/lib.rs
+++ b/dhall_syntax/src/lib.rs
@@ -3,6 +3,7 @@
#![feature(try_blocks)]
#![feature(never_type)]
#![feature(proc_macro_hygiene)]
+#![feature(type_alias_enum_variants)]
#![allow(
clippy::many_single_char_names,
clippy::should_implement_trait,
diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs
index fac6ecc..b1e429b 100644
--- a/dhall_syntax/src/parser.rs
+++ b/dhall_syntax/src/parser.rs
@@ -30,7 +30,7 @@ pub type ParseResult<T> = Result<T, ParseError>;
#[derive(Debug, Clone)]
struct ParseInput<'input, Rule>
where
- Rule: std::fmt::Debug + Copy + std::hash::Hash + Ord,
+ Rule: pest::RuleType,
{
pair: Pair<'input, Rule>,
original_input_str: Rc<str>,
@@ -70,6 +70,11 @@ impl<'input> ParseInput<'input, Rule> {
}
}
+// Used to retrieve the `Rule` enum associated with the `Self` type in `parse_children`.
+trait PestConsumer {
+ type RuleEnum: pest::RuleType;
+}
+
fn debug_pair(pair: Pair<Rule>) -> String {
use std::fmt::Write;
let mut s = String::new();
@@ -226,7 +231,7 @@ lazy_static::lazy_static! {
struct Parsers;
-#[make_parser]
+#[make_parser(Rule)]
impl Parsers {
fn EOI(_: ParseInput<Rule>) -> ParseResult<()> {
Ok(())