Gate literal box expressions in addition to types

Closes #10920
This commit is contained in:
Alex Crichton 2013-12-11 23:17:54 -08:00
parent 1b12dca7f9
commit 0f6537fed4
90 changed files with 187 additions and 16 deletions

View File

@ -77,6 +77,14 @@ impl Context {
}
}
fn gate_box(&self, span: Span) {
self.gate_feature("managed_boxes", span,
"The managed box syntax is being replaced by the \
`std::gc::Gc` and `std::rc::Rc` types. Equivalent \
functionality to managed trait objects will be \
implemented but is currently missing.");
}
fn has_feature(&self, feature: &str) -> bool {
self.features.iter().any(|n| n.as_slice() == feature)
}
@ -172,17 +180,24 @@ impl Visitor<()> for Context {
experimental and likely to be removed");
},
ast::ty_box(_) => {
self.gate_feature("managed_boxes", t.span,
"The managed box syntax is being replaced by the `std::gc::Gc` \
and `std::rc::Rc` types. Equivalent functionality to managed \
trait objects will be implemented but is currently missing.");
}
ast::ty_box(_) => { self.gate_box(t.span); }
_ => {}
}
visit::walk_ty(self, t, ());
}
fn visit_expr(&mut self, e: @ast::Expr, _: ()) {
match e.node {
ast::ExprUnary(_, ast::UnBox(..), _) |
ast::ExprVstore(_, ast::ExprVstoreBox) |
ast::ExprVstore(_, ast::ExprVstoreMutBox) => {
self.gate_box(e.span);
}
_ => {}
}
visit::walk_expr(self, e, ());
}
}
pub fn check_crate(sess: Session, crate: &ast::Crate) {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn main() {
// Testing that method lookup does not automatically borrow

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct Point {
x: int,
y: int,

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct point { x: int, y: int }
trait methods {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn main() {
let v = @mut [ 1, 2, 3 ];
for _x in v.iter() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
mod my_mod {
pub struct MyStruct {
priv priv_field: int

View File

@ -1,6 +1,8 @@
// Tests that references to move-by-default values trigger moves when
// they occur as part of various kinds of expressions.
#[feature(managed_boxes)];
struct Foo<A> { f: A }
fn guard(_s: ~str) -> bool {fail!()}
fn touch<A>(_a: &A) {}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
enum t { a, b, }
fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn main() {
let f; //~ ERROR cyclic type of infinite size
f = @f;

View File

@ -1,3 +1,5 @@
#[feature(managed_boxes)];
fn f<T:'static>(_: T) {}
fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn f<T:Send>(_i: T) {
}

View File

@ -8,6 +8,8 @@
//
// for a detailed explanation of what is going on here.
#[feature(managed_boxes)];
fn main() {
let a = @mut [3i];
let b = @mut [a];

View File

@ -3,6 +3,8 @@
// Test that write guards trigger when there is a write to a field
// of a frozen structure.
#[feature(managed_boxes)];
struct S {
x: int
}

View File

@ -3,6 +3,8 @@
// Test that write guards trigger when there is a write to a directly
// frozen @mut box.
#[feature(managed_boxes)];
fn main() {
let x = @mut 3;
let _y: &mut int = x;

View File

@ -3,6 +3,8 @@
// Test that write guards trigger when there is a coercion to
// a slice on the receiver of a method.
#[feature(managed_boxes)];
trait MyMutSlice {
fn my_mut_slice(self) -> Self;
}

View File

@ -2,6 +2,8 @@
// Test that write guards trigger when arguments are coerced to slices.
#[feature(managed_boxes)];
fn add(x:&mut [int], y:&[int])
{
x[0] = x[0] + y[0];

View File

@ -3,6 +3,8 @@
// Test that write guards trigger when we are indexing into
// an @mut vector.
#[feature(managed_boxes)];
fn add(x:&mut int, y:&int)
{
*x = *x + *y;

View File

@ -3,6 +3,8 @@
// Test that arguments trigger when there are *two mutable* borrows
// of indices.
#[feature(managed_boxes)];
fn add(x:&mut int, y:&mut int)
{
*x = *x + *y;

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn main() {
let _a = @0;
assert!(false);

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
use std::cast;
fn failfn() {

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn failfn() {
fail!();
}

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn failfn() {
fail!();
}

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn failfn() {
fail!();
}

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn failfn() {
fail!();
}

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn failfn() {
fail!();
}

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn main() {
@0;
fail!();

View File

@ -10,6 +10,7 @@
// error-pattern:fail
#[feature(managed_boxes)];
#[allow(unreachable_code)];
#[allow(unused_variable)];

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn x(it: |int|) {
let _a = @0;
it(1);

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
// Issue #945
// error-pattern:non-exhaustive match failure
fn test_box() {

View File

@ -11,6 +11,8 @@
// exec-env:RUST_NEWRT=1
// error-pattern:fail
#[feature(managed_boxes)];
fn main() {
let _count = @mut 0u;
let mut map = std::hashmap::HashMap::new();

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn main() {
let _a = @0;
{

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn f() -> ~[int] { fail!(); }
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn f() -> ~[int] { fail!(); }
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn f() -> ~[int] { fail!(); }
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn f() {
let _a = @0;
fail!();

View File

@ -10,6 +10,8 @@
// error-pattern:fail
#[feature(managed_boxes)];
fn f() {
fail!();
}

View File

@ -11,6 +11,8 @@
// Testing that method lookup automatically both borrows vectors to slices
// and also references them to create the &self pointer
#[feature(managed_boxes)];
trait MyIter {
fn test_imm(&self);
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
trait double {
fn double(@self) -> uint;
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
trait double {
fn double(@self) -> uint;
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn sum_slice(x: &[int]) -> int {
let mut sum = 0;
for i in x.iter() { sum += *i; }

View File

@ -10,6 +10,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
use std::ptr;
struct F { f: ~int }

View File

@ -12,6 +12,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
use std::ptr;
fn borrow(x: &int, f: |x: &int|) {

View File

@ -10,6 +10,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
use std::ptr;
struct F { f: ~int }

View File

@ -12,6 +12,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
use std::ptr;
fn borrow(x: &int, f: |x: &int|) {

View File

@ -12,6 +12,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
use std::ptr;
fn borrow(x: &int, f: |x: &int|) {

View File

@ -10,6 +10,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
fn testfn(cond: bool) {
let mut x = @3;
let mut y = @4;

View File

@ -12,6 +12,8 @@
// exec-env:RUST_POISON_ON_FREE=1
#[feature(managed_boxes)];
use std::ptr;
fn borrow(x: &int, f: |x: &int|) {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
enum newtype {
newtype(int)
}

View File

@ -26,6 +26,7 @@
//
// run-fail/borrowck-wg-autoderef-and-autoborrowvec-combined-fail-issue-6272.rs
#[feature(managed_boxes)];
pub fn main() {
let a = @mut 3i;

View File

@ -1,3 +1,5 @@
#[feature(managed_boxes)];
fn f(x: &int) {
println(x.to_str());
}

View File

@ -1,5 +1,7 @@
// Test that we can borrow the same @mut box twice, so long as both are imm.
#[feature(managed_boxes)];
fn add(x:&int, y:&int)
{
*x + *y;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
pub fn main() {
let (&x, &y, &z) = (&3, &'a', &@"No pets!");
assert_eq!(x, 3);

View File

@ -11,6 +11,8 @@
// xfail-fast - check-fast doesn't understand aux-build
// aux-build:cci_borrow_lib.rs
#[feature(managed_boxes)];
extern mod cci_borrow_lib;
use cci_borrow_lib::foo;

View File

@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
pub fn main() { let x = @mut 5; *x = 1000; info!("{:?}", *x); }

View File

@ -13,7 +13,7 @@
// xfail-fast
#[feature(struct_variant)];
#[feature(struct_variant, managed_boxes)];
extern mod extra;

View File

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
pub fn main() { let x = { @100 }; assert!((*x == 100)); }

View File

@ -8,5 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
// Regression test for issue #388
pub fn main() { let _x = { { @10 } }; }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
// Regression test for issue #388
pub fn main() {
let _x = if false {

View File

@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
// Tests for if as expressions returning boxed types
fn test_box() {

View File

@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
// Tests for match as expressions resulting in boxed types
fn test_box() {

View File

@ -10,6 +10,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
/**
A somewhat reduced test case to expose some Valgrind issues.

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
mod rusti {
extern "rust-intrinsic" {
pub fn move_val_init<T>(dst: &mut T, src: T);

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct Font {
fontbuf: uint,
cairo_font: uint,

View File

@ -10,6 +10,9 @@
// xfail-fast
// aux-build:issue-3012-1.rs
#[feature(managed_boxes)];
extern mod socketlib;
use socketlib::socket;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct Foo { x: int }
impl Foo {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
use std::hashmap::HashMap;
pub fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
pub fn main() {
let box1 = @mut 42;
let _x = *(&mut *box1) == 42 || *(&mut *box1) == 31337;

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
#[allow(unused_mut)];
pub fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
pub fn main() {
match Left(@17) {
Right(()) => {}

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn assert_repr_eq<T>(obj : T, expected : ~str) {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
#[allow(unnecessary_allocation)];
// Tests for a previous bug that occured due to an interaction

View File

@ -11,6 +11,7 @@
// This should typecheck even though the type of e is not fully
// resolved when we finish typechecking the ||.
#[feature(managed_boxes)];
struct Refs { refs: ~[int], n: int }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct xx(int);
struct X { x: xx, y: int }

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct X { x: int, y: int, z: int }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct Foo { foo: bool, bar: Option<int>, baz: int }
pub fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
trait get {
fn get(self) -> int;
}

View File

@ -10,6 +10,8 @@
/* Tests conditional rooting of the box y */
#[feature(managed_boxes)];
fn testfn(cond: bool) {
let mut x = @3;
let mut y = @4;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn foo(x: &uint) -> uint {
*x
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn foo(x: &[uint]) -> uint {
x[0]
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn foo<'r>(x: &'r uint) -> &'r uint { x }
fn bar(x: &uint) -> uint { *x }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn borrow<'r, T>(x: &'r T) -> &'r T {x}
pub fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
struct Point {x: int, y: int}
fn x_coord<'r>(p: &'r Point) -> &'r int {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
#[deriving(Clone)]
struct Foo {
a: ~str,

View File

@ -1,3 +1,5 @@
#[feature(managed_boxes)];
struct Foo<'a> {
x: &'a int
}

View File

@ -10,6 +10,8 @@
// xfail-fast
#[feature(managed_boxes)];
fn p_foo<T>(_pinned: T) { }
fn s_foo<T>(_shared: T) { }
fn u_foo<T:Send>(_unique: T) { }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn f<T>(t: T) -> T {
let t1 = t;
t1

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
#[allow(unused_variable)];
use std::managed;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
extern mod extra;
use std::task;

View File

@ -1,3 +1,5 @@
#[feature(managed_boxes)];
pub fn main() {
let x = @[1, 2, 3];
match x {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
pub fn main() {
assert_eq!((~[0, 1]).to_str(), ~"[0, 1]");
assert_eq!((&[1, 2]).to_str(), ~"[1, 2]");