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