2017-10-11 09:39:45 -05:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
// revisions: ast mir
|
2017-11-19 16:37:59 -06:00
|
|
|
//[mir]compile-flags: -Z borrowck=mir
|
2017-10-11 09:39:45 -05:00
|
|
|
|
2017-10-13 08:36:15 -05:00
|
|
|
enum Foo {
|
|
|
|
A(i32),
|
|
|
|
B
|
|
|
|
}
|
|
|
|
|
|
|
|
fn match_enum() {
|
|
|
|
let mut foo = Foo::B;
|
|
|
|
let p = &mut foo;
|
2018-02-09 08:49:38 -06:00
|
|
|
let _ = match foo { //[mir]~ ERROR [E0503]
|
2017-11-19 16:37:59 -06:00
|
|
|
Foo::B => 1, //[mir]~ ERROR [E0503]
|
2017-10-13 08:36:15 -05:00
|
|
|
_ => 2,
|
|
|
|
Foo::A(x) => x //[ast]~ ERROR [E0503]
|
2017-11-19 16:37:59 -06:00
|
|
|
//[mir]~^ ERROR [E0503]
|
2017-10-13 08:36:15 -05:00
|
|
|
};
|
2018-04-09 04:28:00 -05:00
|
|
|
drop(p);
|
2017-10-13 08:36:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-11 09:39:45 -05:00
|
|
|
fn main() {
|
|
|
|
let mut x = 1;
|
2018-04-09 04:28:00 -05:00
|
|
|
let r = &mut x;
|
2018-02-09 08:49:38 -06:00
|
|
|
let _ = match x { //[mir]~ ERROR [E0503]
|
2017-11-19 16:37:59 -06:00
|
|
|
x => x + 1, //[ast]~ ERROR [E0503]
|
|
|
|
//[mir]~^ ERROR [E0503]
|
2017-10-11 09:39:45 -05:00
|
|
|
y => y + 2, //[ast]~ ERROR [E0503]
|
2017-11-19 16:37:59 -06:00
|
|
|
//[mir]~^ ERROR [E0503]
|
2017-10-11 09:39:45 -05:00
|
|
|
};
|
2018-04-09 04:28:00 -05:00
|
|
|
drop(r);
|
2017-10-11 09:39:45 -05:00
|
|
|
}
|