2015-07-17 09:16:22 -05:00
|
|
|
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
|
2014-10-01 11:53:10 -05:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// Test that we correctly compute the move fragments for a fn.
|
|
|
|
//
|
|
|
|
// Note that the code below is not actually incorrect; the
|
|
|
|
// `rustc_move_fragments` attribute is a hack that uses the error
|
|
|
|
// reporting mechanisms as a channel for communicating from the
|
|
|
|
// internals of the compiler.
|
|
|
|
|
|
|
|
// This checks the handling of `_` within variants, especially when mixed
|
|
|
|
// with bindings.
|
|
|
|
|
2015-02-16 14:21:41 -06:00
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
2014-10-01 11:53:10 -05:00
|
|
|
use self::Lonely::{Zero, One, Two};
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
pub struct D { d: isize }
|
2014-10-01 11:53:10 -05:00
|
|
|
impl Drop for D { fn drop(&mut self) { } }
|
|
|
|
|
|
|
|
pub enum Lonely<X,Y> { Zero, One(X), Two(X, Y) }
|
|
|
|
|
|
|
|
#[rustc_move_fragments]
|
|
|
|
pub fn test_match_bind_and_underscore(p: Lonely<D, D>) {
|
|
|
|
//~^ ERROR parent_of_fragments: `$(local p)`
|
2015-07-17 09:16:22 -05:00
|
|
|
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)`
|
|
|
|
//~| ERROR assigned_leaf_path: `($(local p) as Lonely::One)`
|
|
|
|
//~| ERROR parent_of_fragments: `($(local p) as Lonely::Two)`
|
|
|
|
//~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#0`
|
|
|
|
//~| ERROR unmoved_fragment: `($(local p) as Lonely::Two).#1`
|
2014-10-01 11:53:10 -05:00
|
|
|
//~| ERROR assigned_leaf_path: `$(local left)`
|
|
|
|
|
|
|
|
match p {
|
2015-10-26 13:10:41 -05:00
|
|
|
Zero => {}
|
2014-10-01 11:53:10 -05:00
|
|
|
|
|
|
|
One(_) => {} // <-- does not fragment `($(local p) as One)` ...
|
|
|
|
|
|
|
|
Two(left, _) => {} // <-- ... *does* fragment `($(local p) as Two)`.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() { }
|