diff options
| author | Sebastian Malton <sebastian@malton.name> | 2018-06-03 23:31:49 -0400 |
|---|---|---|
| committer | Jake Goulding <jake.goulding@gmail.com> | 2018-06-05 10:19:21 -0400 |
| commit | 4fe40635ef3c2cdbc2e3f62ca71f0e2235e70639 (patch) | |
| tree | 94089961baf76e9fd6ad1ce82c65de281bc74c52 /src/test/compile-fail | |
| parent | 4122885e0f99b3f28e65c122cde48de5bfc8231a (diff) | |
| download | rust-4fe40635ef3c2cdbc2e3f62ca71f0e2235e70639.tar.gz rust-4fe40635ef3c2cdbc2e3f62ca71f0e2235e70639.zip | |
Implementation of RFC 2086 - Allow Irrefutable Let patterns
Diffstat (limited to 'src/test/compile-fail')
3 files changed, 49 insertions, 0 deletions
diff --git a/src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs b/src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs new file mode 100644 index 00000000000..1facb6b152a --- /dev/null +++ b/src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs @@ -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] +} diff --git a/src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs b/src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs new file mode 100644 index 00000000000..71dcbf329c7 --- /dev/null +++ b/src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs @@ -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] +} diff --git a/src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.rs b/src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.rs new file mode 100644 index 00000000000..2f9b7f0628d --- /dev/null +++ b/src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.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. + +#![feature(irrefutable_let_pattern)] + +// should-fail-irrefutable_let_pattern_with_gate +fn main() { + if let _ = 5 {} + //~^ ERROR irrefutable if-let pattern [irrefutable_let_pattern] +} |
