]> git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / ui / borrowck / move-in-static-initializer-issue-38520.rs
1 // Copyright 2012 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 // revisions: ast mir
12 //[mir]compile-flags: -Z borrowck=mir
13
14 // Regression test for #38520. Check that moves of `Foo` are not
15 // permitted as `Foo` is not copy (even in a static/const
16 // initializer).
17
18 struct Foo(usize);
19
20 const fn get(x: Foo) -> usize {
21 x.0
22 }
23
24 const X: Foo = Foo(22);
25 static Y: usize = get(*&X); //[ast]~ ERROR E0507
26 //[mir]~^ ERROR [E0507]
27 const Z: usize = get(*&X); //[ast]~ ERROR E0507
28 //[mir]~^ ERROR [E0507]
29
30 fn main() {
31 }