]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/move-fragments-3.rs
New upstream version 1.18.0+dfsg1
[rustc.git] / src / test / compile-fail / move-fragments-3.rs
CommitLineData
c1a9b12d 1// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
1a4d82fc
JJ
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 that we correctly compute the move fragments for a fn.
12//
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.
17
18// This checks the handling of `_` within variants, especially when mixed
19// with bindings.
20
85aaf69f
SL
21#![feature(rustc_attrs)]
22
1a4d82fc
JJ
23use self::Lonely::{Zero, One, Two};
24
25pub struct D { d: isize }
26impl Drop for D { fn drop(&mut self) { } }
27
28pub enum Lonely<X,Y> { Zero, One(X), Two(X, Y) }
29
30#[rustc_move_fragments]
31pub fn test_match_bind_and_underscore(p: Lonely<D, D>) {
32 //~^ ERROR parent_of_fragments: `$(local p)`
c1a9b12d
SL
33 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
34 //~| ERROR assigned_leaf_path: `($(local p) as Lonely::One)`
35 //~| ERROR parent_of_fragments: `($(local p) as Lonely::Two)`
36 //~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#0`
37 //~| ERROR unmoved_fragment: `($(local p) as Lonely::Two).#1`
1a4d82fc
JJ
38 //~| ERROR assigned_leaf_path: `$(local left)`
39
40 match p {
92a42be0 41 Zero => {}
1a4d82fc
JJ
42
43 One(_) => {} // <-- does not fragment `($(local p) as One)` ...
44
45 Two(left, _) => {} // <-- ... *does* fragment `($(local p) as Two)`.
46 }
47}
48
49pub fn main() { }