]> git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs
Update upstream source from tag 'upstream/1.30.0_beta.7+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 #![feature(min_const_fn)]
19
20 struct Foo(usize);
21
22 const fn get(x: Foo) -> usize {
23 x.0
24 }
25
26 const X: Foo = Foo(22);
27 static Y: usize = get(*&X); //[ast]~ ERROR E0507
28 //[mir]~^ ERROR [E0507]
29 const Z: usize = get(*&X); //[ast]~ ERROR E0507
30 //[mir]~^ ERROR [E0507]
31
32 fn main() {
33 }