diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e1b7d4681ad16..933cce13549fe 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -659,12 +659,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "rustc_attrs", "internal rustc attributes will never be stable", cfg_fn!(rustc_attrs))), - ("rustc_move_fragments", Normal, Gated(Stability::Unstable, - "rustc_attrs", - "the `#[rustc_move_fragments]` attribute \ - is just used for rustc unit tests \ - and will never be stable", - cfg_fn!(rustc_attrs))), ("rustc_mir", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "the `#[rustc_mir]` attribute \ diff --git a/src/test/compile-fail/feature-gate-rustc-attrs.rs b/src/test/compile-fail/feature-gate-rustc-attrs.rs index bb5b70829a163..8cfd3e020c69a 100644 --- a/src/test/compile-fail/feature-gate-rustc-attrs.rs +++ b/src/test/compile-fail/feature-gate-rustc-attrs.rs @@ -14,7 +14,6 @@ #[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable -#[rustc_move_fragments] //~ ERROR the `#[rustc_move_fragments]` attribute is just used for rustc unit tests and will never be stable #[rustc_foo] //~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics diff --git a/src/test/compile-fail/move-fragments-1.rs b/src/test/compile-fail/move-fragments-1.rs deleted file mode 100644 index 0219f5b6becb3..0000000000000 --- a/src/test/compile-fail/move-fragments-1.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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. - -// These are all fairly trivial cases: unused variables or direct -// drops of substructure. - -#![feature(rustc_attrs)] - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -#[rustc_move_fragments] -pub fn test_noop() { -} - -#[rustc_move_fragments] -pub fn test_take(_x: D) { - //~^ ERROR assigned_leaf_path: `$(local _x)` -} - -pub struct Pair { x: X, y: Y } - -#[rustc_move_fragments] -pub fn test_take_struct(_p: Pair) { - //~^ ERROR assigned_leaf_path: `$(local _p)` -} - -#[rustc_move_fragments] -pub fn test_drop_struct_part(p: Pair) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR moved_leaf_path: `$(local p).x` - //~| ERROR unmoved_fragment: `$(local p).y` - drop(p.x); -} - -#[rustc_move_fragments] -pub fn test_drop_tuple_part(p: (D, D)) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR moved_leaf_path: `$(local p).#0` - //~| ERROR unmoved_fragment: `$(local p).#1` - drop(p.0); -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-2.rs b/src/test/compile-fail/move-fragments-2.rs deleted file mode 100644 index 15c28ec2713e9..0000000000000 --- a/src/test/compile-fail/move-fragments-2.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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. - -// These are checking that enums are tracked; note that their output -// paths include "downcasts" of the path to a particular enum. - -#![feature(rustc_attrs)] - -use self::Lonely::{Zero, One, Two}; - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -pub enum Lonely { Zero, One(X), Two(X, Y) } - -#[rustc_move_fragments] -pub fn test_match_partial(p: Lonely) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)` - match p { - Zero => {} - _ => {} - } -} - -#[rustc_move_fragments] -pub fn test_match_full(p: Lonely) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::One)` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Two)` - match p { - Zero => {} - One(..) => {} - Two(..) => {} - } -} - -#[rustc_move_fragments] -pub fn test_match_bind_one(p: Lonely) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)` - //~| ERROR parent_of_fragments: `($(local p) as Lonely::One)` - //~| ERROR moved_leaf_path: `($(local p) as Lonely::One).#0` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Two)` - //~| ERROR assigned_leaf_path: `$(local data)` - match p { - Zero => {} - One(data) => {} - Two(..) => {} - } -} - -#[rustc_move_fragments] -pub fn test_match_bind_many(p: Lonely) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR assigned_leaf_path: `($(local p) as Lonely::Zero)` - //~| ERROR parent_of_fragments: `($(local p) as Lonely::One)` - //~| ERROR moved_leaf_path: `($(local p) as Lonely::One).#0` - //~| ERROR assigned_leaf_path: `$(local data)` - //~| ERROR parent_of_fragments: `($(local p) as Lonely::Two)` - //~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#0` - //~| ERROR moved_leaf_path: `($(local p) as Lonely::Two).#1` - //~| ERROR assigned_leaf_path: `$(local left)` - //~| ERROR assigned_leaf_path: `$(local right)` - match p { - Zero => {} - One(data) => {} - Two(left, right) => {} - } -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-3.rs b/src/test/compile-fail/move-fragments-3.rs deleted file mode 100644 index a1152333900a0..0000000000000 --- a/src/test/compile-fail/move-fragments-3.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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. - -#![feature(rustc_attrs)] - -use self::Lonely::{Zero, One, Two}; - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -pub enum Lonely { Zero, One(X), Two(X, Y) } - -#[rustc_move_fragments] -pub fn test_match_bind_and_underscore(p: Lonely) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| 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` - //~| ERROR assigned_leaf_path: `$(local left)` - - match p { - Zero => {} - - One(_) => {} // <-- does not fragment `($(local p) as One)` ... - - Two(left, _) => {} // <-- ... *does* fragment `($(local p) as Two)`. - } -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-4.rs b/src/test/compile-fail/move-fragments-4.rs deleted file mode 100644 index 191e23a28638b..0000000000000 --- a/src/test/compile-fail/move-fragments-4.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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 that a move of deep structure is properly tracked. (An -// early draft of the code did not properly traverse up through all of -// the parents of the leaf fragment.) - -#![feature(rustc_attrs)] - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -pub struct Pair { x: X, y: Y } - -#[rustc_move_fragments] -pub fn test_move_substructure(pppp: Pair, D>, D>, D>) { - //~^ ERROR parent_of_fragments: `$(local pppp)` - //~| ERROR parent_of_fragments: `$(local pppp).x` - //~| ERROR parent_of_fragments: `$(local pppp).x.x` - //~| ERROR unmoved_fragment: `$(local pppp).x.x.x` - //~| ERROR moved_leaf_path: `$(local pppp).x.x.y` - //~| ERROR unmoved_fragment: `$(local pppp).x.y` - //~| ERROR unmoved_fragment: `$(local pppp).y` - drop(pppp.x.x.y); -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-5.rs b/src/test/compile-fail/move-fragments-5.rs deleted file mode 100644 index 38a385eacac5c..0000000000000 --- a/src/test/compile-fail/move-fragments-5.rs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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 is the first test that checks moving into local variables. - -#![feature(rustc_attrs)] - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -pub struct Pair { x: X, y: Y } - -#[rustc_move_fragments] -pub fn test_move_field_to_local(p: Pair) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR moved_leaf_path: `$(local p).x` - //~| ERROR unmoved_fragment: `$(local p).y` - //~| ERROR assigned_leaf_path: `$(local _x)` - let _x = p.x; -} - -#[rustc_move_fragments] -pub fn test_move_field_to_local_to_local(p: Pair) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR moved_leaf_path: `$(local p).x` - //~| ERROR unmoved_fragment: `$(local p).y` - //~| ERROR assigned_leaf_path: `$(local _x)` - //~| ERROR moved_leaf_path: `$(local _x)` - //~| ERROR assigned_leaf_path: `$(local _y)` - let _x = p.x; - let _y = _x; -} - -// In the following fn's `test_move_field_to_local_delayed` and -// `test_uninitialized_local` , the instrumentation reports that `_x` -// is moved. This is unlike `test_move_field_to_local`, where `_x` is -// just reported as an assigned_leaf_path. Presumably because this is -// how we represent that it did not have an initializing expression at -// the binding site. - -#[rustc_move_fragments] -pub fn test_uninitialized_local(_p: Pair) { - //~^ ERROR assigned_leaf_path: `$(local _p)` - //~| ERROR moved_leaf_path: `$(local _x)` - let _x: D; -} - -#[rustc_move_fragments] -pub fn test_move_field_to_local_delayed(p: Pair) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR moved_leaf_path: `$(local p).x` - //~| ERROR unmoved_fragment: `$(local p).y` - //~| ERROR assigned_leaf_path: `$(local _x)` - //~| ERROR moved_leaf_path: `$(local _x)` - let _x; - _x = p.x; -} - -#[rustc_move_fragments] -pub fn test_move_field_mut_to_local(mut p: Pair) { - //~^ ERROR parent_of_fragments: `$(local mut p)` - //~| ERROR moved_leaf_path: `$(local mut p).x` - //~| ERROR unmoved_fragment: `$(local mut p).y` - //~| ERROR assigned_leaf_path: `$(local _x)` - let _x = p.x; -} - -#[rustc_move_fragments] -pub fn test_move_field_to_local_to_local_mut(p: Pair) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR moved_leaf_path: `$(local p).x` - //~| ERROR unmoved_fragment: `$(local p).y` - //~| ERROR assigned_leaf_path: `$(local mut _x)` - //~| ERROR moved_leaf_path: `$(local mut _x)` - //~| ERROR assigned_leaf_path: `$(local _y)` - let mut _x = p.x; - let _y = _x; -} - -pub fn main() {} diff --git a/src/test/compile-fail/move-fragments-6.rs b/src/test/compile-fail/move-fragments-6.rs deleted file mode 100644 index 122727c3f6b64..0000000000000 --- a/src/test/compile-fail/move-fragments-6.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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. - -// Test that moving into a field (i.e. overwriting it) fragments the -// receiver. - -#![feature(rustc_attrs)] - -use std::mem::drop; - -pub struct Pair { x: X, y: Y } - -#[rustc_move_fragments] -pub fn test_overwrite_uninit_field(z: Z) { - //~^ ERROR parent_of_fragments: `$(local mut p)` - //~| ERROR assigned_leaf_path: `$(local z)` - //~| ERROR moved_leaf_path: `$(local z)` - //~| ERROR assigned_leaf_path: `$(local mut p).x` - //~| ERROR unmoved_fragment: `$(local mut p).y` - - let mut p: Pair; - p.x = z; -} - -#[rustc_move_fragments] -pub fn test_overwrite_moved_field(mut p: Pair, z: Z) { - //~^ ERROR parent_of_fragments: `$(local mut p)` - //~| ERROR assigned_leaf_path: `$(local z)` - //~| ERROR moved_leaf_path: `$(local z)` - //~| ERROR assigned_leaf_path: `$(local mut p).y` - //~| ERROR unmoved_fragment: `$(local mut p).x` - - drop(p); - p.y = z; -} - -#[rustc_move_fragments] -pub fn test_overwrite_same_field(mut p: Pair) { - //~^ ERROR parent_of_fragments: `$(local mut p)` - //~| ERROR moved_leaf_path: `$(local mut p).x` - //~| ERROR assigned_leaf_path: `$(local mut p).x` - //~| ERROR unmoved_fragment: `$(local mut p).y` - - p.x = p.x; -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-7.rs b/src/test/compile-fail/move-fragments-7.rs deleted file mode 100644 index a2a37208cd616..0000000000000 --- a/src/test/compile-fail/move-fragments-7.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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. - -// Test that moving a Box fragments its containing structure, for -// both moving out of the structure (i.e. reading `*p.x`) and writing -// into the container (i.e. writing `*p.x`). - -#![feature(rustc_attrs)] - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -pub struct Pair { x: X, y: Y } - -#[rustc_move_fragments] -pub fn test_deref_box_field(p: Pair, Box>) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR parent_of_fragments: `$(local p).x` - //~| ERROR moved_leaf_path: `$(local p).x.*` - //~| ERROR unmoved_fragment: `$(local p).y` - //~| ERROR assigned_leaf_path: `$(local i)` - let i : D = *p.x; -} - -#[rustc_move_fragments] -pub fn test_overwrite_deref_box_field(mut p: Pair, Box>) { - //~^ ERROR parent_of_fragments: `$(local mut p)` - //~| ERROR parent_of_fragments: `$(local mut p).x` - //~| ERROR assigned_leaf_path: `$(local mut p).x.*` - //~| ERROR unmoved_fragment: `$(local mut p).y` - *p.x = D { d: 3 }; -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-8.rs b/src/test/compile-fail/move-fragments-8.rs deleted file mode 100644 index e57268dbfa32a..0000000000000 --- a/src/test/compile-fail/move-fragments-8.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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. - -// Test that assigning into a `&T` within structured container does -// *not* fragment its containing structure. -// -// Compare against the `Box` handling in move-fragments-7.rs. Note -// also that in this case we cannot do a move out of `&T`, so we only -// test writing `*p.x` here. - -#![feature(rustc_attrs)] - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -pub struct Pair { x: X, y: Y } - -#[rustc_move_fragments] -pub fn test_overwrite_deref_ampersand_field<'a>(p: Pair<&'a mut D, &'a D>) { - //~^ ERROR parent_of_fragments: `$(local p)` - //~| ERROR parent_of_fragments: `$(local p).x` - //~| ERROR assigned_leaf_path: `$(local p).x.*` - //~| ERROR unmoved_fragment: `$(local p).y` - *p.x = D { d: 3 }; -} - -pub fn main() { } diff --git a/src/test/compile-fail/move-fragments-9.rs b/src/test/compile-fail/move-fragments-9.rs deleted file mode 100644 index 350f416903400..0000000000000 --- a/src/test/compile-fail/move-fragments-9.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test moving array structures, e.g. `[T; 3]` as well as moving -// elements in and out of such arrays. -// -// Note also that the `test_move_array_then_overwrite` tests represent -// cases that we probably should make illegal. - -#![feature(rustc_attrs)] - -pub struct D { d: isize } -impl Drop for D { fn drop(&mut self) { } } - -#[rustc_move_fragments] -pub fn test_move_array_via_return(a: [D; 3]) -> [D; 3] { - //~^ ERROR assigned_leaf_path: `$(local a)` - //~| ERROR moved_leaf_path: `$(local a)` - return a; -} - -#[rustc_move_fragments] -pub fn test_move_array_into_recv(a: [D; 3], recv: &mut [D; 3]) { - //~^ ERROR parent_of_fragments: `$(local recv)` - //~| ERROR assigned_leaf_path: `$(local a)` - //~| ERROR moved_leaf_path: `$(local a)` - //~| ERROR assigned_leaf_path: `$(local recv).*` - *recv = a; -} - -#[rustc_move_fragments] -pub fn test_overwrite_array_elem(mut a: [D; 3], i: usize, d: D) { - //~^ ERROR parent_of_fragments: `$(local mut a)` - //~| ERROR assigned_leaf_path: `$(local i)` - //~| ERROR assigned_leaf_path: `$(local d)` - //~| ERROR moved_leaf_path: `$(local d)` - //~| ERROR assigned_leaf_path: `$(local mut a).[]` - //~| ERROR unmoved_fragment: `$(allbutone $(local mut a).[])` - a[i] = d; -} - -pub fn main() { }