From efa7b12a782d9354888c51a300528cf85e4f2ce8 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Thu, 16 Nov 2017 21:12:01 +0900 Subject: [PATCH] Add test --- src/test/compile-fail/const-match-check.rs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/compile-fail/const-match-check.rs diff --git a/src/test/compile-fail/const-match-check.rs b/src/test/compile-fail/const-match-check.rs new file mode 100644 index 00000000000..36a6600b62d --- /dev/null +++ b/src/test/compile-fail/const-match-check.rs @@ -0,0 +1,44 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: matchck eval1 eval2 + +#[cfg(matchck)] +const X: i32 = { let 0 = 0; 0 }; +//[matchck]~^ ERROR refutable pattern in local binding + +#[cfg(matchck)] +static Y: i32 = { let 0 = 0; 0 }; +//[matchck]~^ ERROR refutable pattern in local binding + +#[cfg(matchck)] +trait Bar { + const X: i32 = { let 0 = 0; 0 }; + //[matchck]~^ ERROR refutable pattern in local binding +} + +#[cfg(matchck)] +impl Bar for () { + const X: i32 = { let 0 = 0; 0 }; + //[matchck]~^ ERROR refutable pattern in local binding +} + +#[cfg(eval1)] +enum Foo { + A = { let 0 = 0; 0 }, + //[eval1]~^ ERROR refutable pattern in local binding +} + +fn main() { + #[cfg(eval2)] + let x: [i32; { let 0 = 0; 0 }] = []; + //[eval2]~^ ERROR refutable pattern in local binding + //[eval2]~| ERROR constant evaluation error +}