Rollup merge of #22544 - bombless:fix-pattern, r=pnkfelix
This commit is contained in:
commit
f1a6d67e5e
src
libsyntax/parse
test
@ -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);
|
||||
|
17
src/test/compile-fail/issue-22426-1.rs
Normal file
17
src/test/compile-fail/issue-22426-1.rs
Normal file
@ -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: `<`
|
||||
_ => ()
|
||||
}
|
||||
}
|
12
src/test/compile-fail/issue-22426-2.rs
Normal file
12
src/test/compile-fail/issue-22426-2.rs
Normal file
@ -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: `<`
|
22
src/test/compile-fail/issue-22426-3.rs
Normal file
22
src/test/compile-fail/issue-22426-3.rs
Normal file
@ -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!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
src/test/run-pass/issue-22426.rs
Normal file
16
src/test/run-pass/issue-22426.rs
Normal file
@ -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 => (),
|
||||
_ => ()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user