diff options
author | Nadrieril | 2019-09-02 17:02:06 +0200 |
---|---|---|
committer | Nadrieril | 2019-09-02 17:02:06 +0200 |
commit | 98b53bfe084fcdb58207de19fccbd9ac10a7baf7 (patch) | |
tree | 240d455bba40d81ba7b4f0f1e1259fb4175471be | |
parent | 3e9aa3e46bd5906469751c908a0daedfe26dac22 (diff) |
Avoid use of bind_by_move_pattern_guards feature
Diffstat (limited to '')
-rw-r--r-- | dhall_proc_macros/src/parser.rs | 11 | ||||
-rw-r--r-- | dhall_syntax/src/lib.rs | 1 |
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, |