From 258ec30116b1a80f4a9fb4b14aa22dd88eb8bf31 Mon Sep 17 00:00:00 2001 From: Wonwoo Choi Date: Tue, 5 Sep 2017 18:25:42 +0900 Subject: [PATCH] Expect pipe symbol after closure parameter lists --- src/libsyntax/parse/parser.rs | 2 +- src/test/compile-fail/issue-44021.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/issue-44021.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1f033b25fe4f6..a52d048830715 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4699,7 +4699,7 @@ impl<'a> Parser<'a> { SeqSep::trailing_allowed(token::Comma), |p| p.parse_fn_block_arg() ); - self.bump(); + self.expect(&token::BinOp(token::Or))?; args } }; diff --git a/src/test/compile-fail/issue-44021.rs b/src/test/compile-fail/issue-44021.rs new file mode 100644 index 0000000000000..b6ec21b94c73f --- /dev/null +++ b/src/test/compile-fail/issue-44021.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct MyStruct; +impl MyStruct { + fn f() {|x, y} //~ ERROR expected one of `:`, `@`, or `|`, found `}` +} + +fn main() {}