1 // Copyright 2014-2015 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 // These are checking that enums are tracked; note that their output
19 // paths include "downcasts" of the path to a particular enum.
21 #![feature(rustc_attrs)]
23 use self::Lonely
::{Zero, One, Two}
;
25 pub struct D { d: isize }
26 impl Drop
for D { fn drop(&mut self) { }
}
28 pub enum Lonely
<X
,Y
> { Zero, One(X), Two(X, Y) }
30 #[rustc_move_fragments]
31 pub fn test_match_partial(p
: Lonely
<D
, D
>) {
32 //~^ ERROR parent_of_fragments: `$(local p)`
33 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
40 #[rustc_move_fragments]
41 pub fn test_match_full(p
: Lonely
<D
, D
>) {
42 //~^ ERROR parent_of_fragments: `$(local p)`
43 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
44 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::One)`
45 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Two)`
53 #[rustc_move_fragments]
54 pub fn test_match_bind_one(p
: Lonely
<D
, D
>) {
55 //~^ ERROR parent_of_fragments: `$(local p)`
56 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
57 //~| ERROR parent_of_fragments: `($(local p) as Lonely::One)`
58 //~| ERROR moved_leaf_path: `($(local p) as Lonely::One).#0`
59 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Two)`
60 //~| ERROR assigned_leaf_path: `$(local data)`
68 #[rustc_move_fragments]
69 pub fn test_match_bind_many(p
: Lonely
<D
, D
>) {
70 //~^ ERROR parent_of_fragments: `$(local p)`
71 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
72 //~| ERROR parent_of_fragments: `($(local p) as Lonely::One)`
73 //~| ERROR moved_leaf_path: `($(local p) as Lonely::One).#0`
74 //~| ERROR assigned_leaf_path: `$(local data)`
75 //~| ERROR parent_of_fragments: `($(local p) as Lonely::Two)`
76 //~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#0`
77 //~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#1`
78 //~| ERROR assigned_leaf_path: `$(local left)`
79 //~| ERROR assigned_leaf_path: `$(local right)`
83 Two(left
, right
) => {}