diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-23 14:57:21 +0530 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-23 11:43:57 -0800 |
| commit | f1a6d67e5e5965c6d149454095261cb48ee22f48 (patch) | |
| tree | ca7bce86c32ee2827e6f2005e54a3f56ecb2f96a | |
| parent | bff94bd3c5d4c7d485e17f38898e2f4599622770 (diff) | |
| parent | b13e072c9eb18796ffa7b61af5de0f0965186d24 (diff) | |
| download | rust-f1a6d67e5e5965c6d149454095261cb48ee22f48.tar.gz rust-f1a6d67e5e5965c6d149454095261cb48ee22f48.zip | |
Rollup merge of #22544 - bombless:fix-pattern, r=pnkfelix
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-22426-1.rs | 17 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-22426-2.rs | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-22426-3.rs | 22 | ||||
| -rw-r--r-- | src/test/run-pass/issue-22426.rs | 16 |
5 files changed, 70 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f43b09ddb9d..7977574b02b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3494,6 +3494,9 @@ impl<'a> Parser<'a> { }; pat = PatIdent(BindByValue(MutImmutable), pth1, sub); } + } else if self.look_ahead(1, |t| *t == token::Lt) { + self.bump(); + self.unexpected() } else { // parse an enum pat let enum_path = self.parse_path(LifetimeAndTypesWithColons); diff --git a/src/test/compile-fail/issue-22426-1.rs b/src/test/compile-fail/issue-22426-1.rs new file mode 100644 index 00000000000..f026a5db551 --- /dev/null +++ b/src/test/compile-fail/issue-22426-1.rs @@ -0,0 +1,17 @@ +// Copyright 2015 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match 42 { + x < 7 => (), + //~^ error: unexpected token: `<` + _ => () + } +} diff --git a/src/test/compile-fail/issue-22426-2.rs b/src/test/compile-fail/issue-22426-2.rs new file mode 100644 index 00000000000..ea5180e3eec --- /dev/null +++ b/src/test/compile-fail/issue-22426-2.rs @@ -0,0 +1,12 @@ +// Copyright 2015 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn a(B<) {} + //~^ error: unexpected token: `<` diff --git a/src/test/compile-fail/issue-22426-3.rs b/src/test/compile-fail/issue-22426-3.rs new file mode 100644 index 00000000000..2e0b5d6b80f --- /dev/null +++ b/src/test/compile-fail/issue-22426-3.rs @@ -0,0 +1,22 @@ +// Copyright 2015 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<T>(T, T); + +impl<T> Foo<T> { + fn foo(&self) { + match *self { + Foo<T>(x, y) => { + //~^ error: unexpected token: `<` + println!("Goodbye, World!") + } + } + } +} diff --git a/src/test/run-pass/issue-22426.rs b/src/test/run-pass/issue-22426.rs new file mode 100644 index 00000000000..b1c8f9c23c5 --- /dev/null +++ b/src/test/run-pass/issue-22426.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match 42 { + x if x < 7 => (), + _ => () + } +} |
