diff options
| author | bombless <bombless@126.com> | 2015-02-19 22:01:57 +0800 |
|---|---|---|
| committer | bombless <bombless@126.com> | 2015-02-19 22:01:57 +0800 |
| commit | 61ea8b33d03b2b434793e6fc8f0a3cc67b90a72a (patch) | |
| tree | b18f374cbb8af04691c743474a27d0e9472c4c1c | |
| parent | b6d91a2bdac45cd919497a24207fab843124d4ba (diff) | |
| download | rust-61ea8b33d03b2b434793e6fc8f0a3cc67b90a72a.tar.gz rust-61ea8b33d03b2b434793e6fc8f0a3cc67b90a72a.zip | |
Fix issue #22426 #22447
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-22426-1.rs | 16 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-22426-2.rs | 11 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-22426.rs | 21 | ||||
| -rw-r--r-- | src/test/run-pass/issue-22426.rs | 21 |
5 files changed, 72 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d2133f03335..680554e2ad7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3496,6 +3496,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..edc56ae1939 --- /dev/null +++ b/src/test/compile-fail/issue-22426-1.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 < 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..c24de36ec75 --- /dev/null +++ b/src/test/compile-fail/issue-22426-2.rs @@ -0,0 +1,11 @@ +// 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.rs b/src/test/compile-fail/issue-22426.rs new file mode 100644 index 00000000000..37625e69a43 --- /dev/null +++ b/src/test/compile-fail/issue-22426.rs @@ -0,0 +1,21 @@ +// 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..d1d1b037d8d --- /dev/null +++ b/src/test/run-pass/issue-22426.rs @@ -0,0 +1,21 @@ +// 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>(ref x, ref y) => { //~ ERROR unexpected token `<` + println!("Goodbye, World!") + } + } + } +} |
