]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/move-in-static-initializer-issue-38520.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / move-in-static-initializer-issue-38520.rs
1 // Regression test for #38520. Check that moves of `Foo` are not
2 // permitted as `Foo` is not copy (even in a static/const
3 // initializer).
4
5 struct Foo(usize);
6
7 const fn get(x: Foo) -> usize {
8     x.0
9 }
10
11 const X: Foo = Foo(22);
12 static Y: usize = get(*&X); //~ ERROR [E0507]
13 const Z: usize = get(*&X); //~ ERROR [E0507]
14
15 fn main() {
16 }