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 assigning into a `&T` within structured container does
19 // *not* fragment its containing structure.
21 // Compare against the `Box<T>` handling in move-fragments-7.rs. Note
22 // also that in this case we cannot do a move out of `&T`, so we only
23 // test writing `*p.x` here.
25 #![feature(rustc_attrs)]
27 pub struct D { d: isize }
28 impl Drop
for D { fn drop(&mut self) { }
}
30 pub struct Pair
<X
,Y
> { x: X, y: Y }
32 #[rustc_move_fragments]
33 pub fn test_overwrite_deref_ampersand_field
<'a
>(p
: Pair
<&'a
mut D
, &'a D
>) {
34 //~^ ERROR parent_of_fragments: `$(local p)`
35 //~| ERROR parent_of_fragments: `$(local p).x`
36 //~| ERROR assigned_leaf_path: `$(local p).x.*`
37 //~| ERROR unmoved_fragment: `$(local p).y`