Implementation of RFC 2086 - Allow Irrefutable Let patterns
This commit is contained in:
parent
4122885e0f
commit
4fe40635ef
8 changed files with 139 additions and 22 deletions
|
|
@ -0,0 +1,17 @@
|
|||
// gate-test-irrefutable_let_pattern
|
||||
|
||||
// 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() {
|
||||
#[allow(irrefutable_let_pattern)]
|
||||
if let _ = 5 {}
|
||||
//~^ ERROR 15:12: 15:13: irrefutable if-let pattern [E0162]
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// 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.
|
||||
|
||||
// should-fail-irrefutable_let_pattern
|
||||
fn main() {
|
||||
if let _ = 5 {}
|
||||
//~^ ERROR irrefutable if-let pattern [E0162]
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
||||
#![feature(irrefutable_let_pattern)]
|
||||
|
||||
// should-fail-irrefutable_let_pattern_with_gate
|
||||
fn main() {
|
||||
if let _ = 5 {}
|
||||
//~^ ERROR irrefutable if-let pattern [irrefutable_let_pattern]
|
||||
}
|
||||
22
src/test/run-pass/allow_irrefutable_let_patterns.rs
Normal file
22
src/test/run-pass/allow_irrefutable_let_patterns.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.
|
||||
|
||||
#![feature(irrefutable_let_pattern)]
|
||||
|
||||
// must-compile-successfully-irrefutable_let_pattern_with_gate
|
||||
fn main() {
|
||||
#[allow(irrefutable_let_pattern)]
|
||||
if let _ = 5 {}
|
||||
|
||||
#[allow(irrefutable_let_pattern)]
|
||||
while let _ = 5 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue