summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dhall_proc_macros/src/parser.rs11
-rw-r--r--dhall_syntax/src/lib.rs1
2 files changed, 9 insertions, 3 deletions
diff --git a/dhall_proc_macros/src/parser.rs b/dhall_proc_macros/src/parser.rs
index 1c75279..f2efb80 100644
--- a/dhall_proc_macros/src/parser.rs
+++ b/dhall_proc_macros/src/parser.rs
@@ -283,7 +283,7 @@ fn make_parser_branch(branch: &ChildrenBranch) -> Result<TokenStream> {
// Convert the input pattern into a pattern-match on the Rules of the children. This uses
// slice_patterns.
// A single pattern just checks that the rule matches; a variable-length pattern binds the
- // subslice and checks that they all match the chosen Rule in the `if`-condition.
+ // subslice and checks, in the if-guard, that its elements all match the chosen Rule.
let variable_pattern_ident =
Ident::new("variable_pattern", Span::call_site());
let match_pat = branch.pattern.iter().map(|item| match item {
@@ -293,7 +293,14 @@ fn make_parser_branch(branch: &ChildrenBranch) -> Result<TokenStream> {
let match_filter = branch.pattern.iter().map(|item| match item {
Single { .. } => quote!(),
Multiple { rule_name, .. } => quote!(
- #variable_pattern_ident.iter().all(|r| r == &Rule::#rule_name) &&
+ {
+ // We can't use .all() directly in the pattern guard without the
+ // bind_by_move_pattern_guards feature.
+ fn all_match(slice: &[Rule]) -> bool {
+ slice.iter().all(|r| r == &Rule::#rule_name)
+ }
+ all_match(#variable_pattern_ident)
+ } &&
),
});
diff --git a/dhall_syntax/src/lib.rs b/dhall_syntax/src/lib.rs
index 290f53c..fb12af4 100644
--- a/dhall_syntax/src/lib.rs
+++ b/dhall_syntax/src/lib.rs
@@ -2,7 +2,6 @@
#![feature(slice_patterns)]
#![feature(try_blocks)]
#![feature(never_type)]
-#![feature(bind_by_move_pattern_guards)]
#![feature(proc_macro_hygiene)]
#![allow(
clippy::many_single_char_names,