summaryrefslogtreecommitdiff
path: root/dhall_proc_macros/src/parser.rs
diff options
context:
space:
mode:
authorNadrieril2019-09-02 17:02:06 +0200
committerNadrieril2019-09-02 17:02:06 +0200
commit98b53bfe084fcdb58207de19fccbd9ac10a7baf7 (patch)
tree240d455bba40d81ba7b4f0f1e1259fb4175471be /dhall_proc_macros/src/parser.rs
parent3e9aa3e46bd5906469751c908a0daedfe26dac22 (diff)
Avoid use of bind_by_move_pattern_guards feature
Diffstat (limited to '')
-rw-r--r--dhall_proc_macros/src/parser.rs11
1 files changed, 9 insertions, 2 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)
+ } &&
),
});