From 98b53bfe084fcdb58207de19fccbd9ac10a7baf7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 2 Sep 2019 17:02:06 +0200 Subject: Avoid use of bind_by_move_pattern_guards feature --- dhall_proc_macros/src/parser.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'dhall_proc_macros') 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 { // 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 { 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) + } && ), }); -- cgit v1.2.3