]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / moves-based-on-type-cyclic-types-issue-4821.rs
CommitLineData
223e47cc
LB
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// Test for a subtle failure computing kinds of cyclic types, in which
12// temporary kinds wound up being stored in a cache and used later.
54a0048b 13// See rustc::ty::type_contents() for more information.
223e47cc 14
223e47cc 15
1a4d82fc 16struct List { key: isize, next: Option<Box<List>> }
223e47cc 17
1a4d82fc 18fn foo(node: Box<List>) -> isize {
223e47cc
LB
19 let r = match node.next {
20 Some(right) => consume(right),
21 None => 0
22 };
23 consume(node) + r //~ ERROR use of partially moved value: `node`
24}
25
1a4d82fc 26fn consume(v: Box<List>) -> isize {
223e47cc
LB
27 v.key
28}
29
30fn main() {}