1 // Copyright 2014 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.
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.
11 // Test that we correctly compute the move fragments for a fn.
13 // Note that the code below is not actually incorrect; the
14 // `rustc_move_fragments` attribute is a hack that uses the error
15 // reporting mechanisms as a channel for communicating from the
16 // internals of the compiler.
18 // Test that moving a Box<T> fragments its containing structure, for
19 // both moving out of the structure (i.e. reading `*p.x`) and writing
20 // into the container (i.e. writing `*p.x`).
22 #![feature(rustc_attrs)]
24 pub struct D { d: isize }
25 impl Drop for D { fn drop(&mut self) { } }
27 pub struct Pair<X,Y> { x: X, y: Y }
29 #[rustc_move_fragments]
30 pub fn test_deref_box_field(p: Pair<Box<D>, Box<D>>) {
31 //~^ ERROR parent_of_fragments: `$(local p)`
32 //~| ERROR parent_of_fragments: `$(local p).x`
33 //~| ERROR moved_leaf_path: `$(local p).x.*`
34 //~| ERROR unmoved_fragment: `$(local p).y`
35 //~| ERROR assigned_leaf_path: `$(local i)`
39 #[rustc_move_fragments]
40 pub fn test_overwrite_deref_box_field(mut p: Pair<Box<D>, Box<D>>) {
41 //~^ ERROR parent_of_fragments: `$(local mut p)`
42 //~| ERROR parent_of_fragments: `$(local mut p).x`
43 //~| ERROR assigned_leaf_path: `$(local mut p).x.*`
44 //~| ERROR unmoved_fragment: `$(local mut p).y`