]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/const-pattern-not-const-evaluable.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / const-pattern-not-const-evaluable.rs
CommitLineData
9cc50fc6
SL
1// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#![feature(const_fn)]
12
13enum Cake {
14 BlackForest,
15 Marmor,
16}
17use Cake::*;
18
19const BOO: (Cake, Cake) = (Marmor, BlackForest);
5bcae85e
SL
20//~^ ERROR: constant evaluation error [E0080]
21//~| unimplemented constant expression: enum variants
9cc50fc6
SL
22const FOO: Cake = BOO.1;
23
24const fn foo() -> Cake {
5bcae85e
SL
25 Marmor
26 //~^ ERROR: constant evaluation error [E0080]
27 //~| unimplemented constant expression: enum variants
28 //~^^^ ERROR: constant evaluation error [E0080]
29 //~| unimplemented constant expression: enum variants
9cc50fc6
SL
30}
31
32const WORKS: Cake = Marmor;
33
5bcae85e 34const GOO: Cake = foo(); //~ NOTE for expression here
9cc50fc6
SL
35
36fn main() {
37 match BlackForest {
5bcae85e
SL
38 FOO => println!("hi"), //~ NOTE: for pattern here
39 GOO => println!("meh"), //~ NOTE: for pattern here
9cc50fc6
SL
40 WORKS => println!("möp"),
41 _ => println!("bye"),
42 }
43}