From 41f598a75de41665dd9ec0aad56b5ef526698151 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 2 Sep 2019 18:46:53 +0200 Subject: Use proper hygiene for `Parsers` and `Rule` --- dhall_syntax/src/lib.rs | 1 + dhall_syntax/src/parser.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'dhall_syntax') 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 = Result; #[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, @@ -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) -> 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) -> ParseResult<()> { Ok(()) -- cgit v1.2.3