Skip to content

Commit 0f6537f

Browse files
committed
Gate literal box expressions in addition to types
Closes #10920
1 parent 1b12dca commit 0f6537f

File tree

90 files changed

+187
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+187
-16
lines changed

src/librustc/front/feature_gate.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ impl Context {
7777
}
7878
}
7979

80+
fn gate_box(&self, span: Span) {
81+
self.gate_feature("managed_boxes", span,
82+
"The managed box syntax is being replaced by the \
83+
`std::gc::Gc` and `std::rc::Rc` types. Equivalent \
84+
functionality to managed trait objects will be \
85+
implemented but is currently missing.");
86+
}
87+
8088
fn has_feature(&self, feature: &str) -> bool {
8189
self.features.iter().any(|n| n.as_slice() == feature)
8290
}
@@ -172,17 +180,24 @@ impl Visitor<()> for Context {
172180
experimental and likely to be removed");
173181

174182
},
175-
ast::ty_box(_) => {
176-
self.gate_feature("managed_boxes", t.span,
177-
"The managed box syntax is being replaced by the `std::gc::Gc` \
178-
and `std::rc::Rc` types. Equivalent functionality to managed \
179-
trait objects will be implemented but is currently missing.");
180-
}
183+
ast::ty_box(_) => { self.gate_box(t.span); }
181184
_ => {}
182185
}
183186

184187
visit::walk_ty(self, t, ());
185188
}
189+
190+
fn visit_expr(&mut self, e: @ast::Expr, _: ()) {
191+
match e.node {
192+
ast::ExprUnary(_, ast::UnBox(..), _) |
193+
ast::ExprVstore(_, ast::ExprVstoreBox) |
194+
ast::ExprVstore(_, ast::ExprVstoreMutBox) => {
195+
self.gate_box(e.span);
196+
}
197+
_ => {}
198+
}
199+
visit::walk_expr(self, e, ());
200+
}
186201
}
187202

188203
pub fn check_crate(sess: Session, crate: &ast::Crate) {

src/test/compile-fail/auto-ref-slice-plus-ref.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
fn main() {
1214

1315
// Testing that method lookup does not automatically borrow

src/test/compile-fail/borrowck-loan-rcvr-overloaded-op.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
struct Point {
1214
x: int,
1315
y: int,

src/test/compile-fail/borrowck-loan-rcvr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
struct point { x: int, y: int }
1214

1315
trait methods {

src/test/compile-fail/borrowck-mut-boxed-vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
fn main() {
1214
let v = @mut [ 1, 2, 3 ];
1315
for _x in v.iter() {

src/test/compile-fail/issue-3763.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
mod my_mod {
1214
pub struct MyStruct {
1315
priv priv_field: int

src/test/compile-fail/moves-based-on-type-exprs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Tests that references to move-by-default values trigger moves when
22
// they occur as part of various kinds of expressions.
33

4+
#[feature(managed_boxes)];
5+
46
struct Foo<A> { f: A }
57
fn guard(_s: ~str) -> bool {fail!()}
68
fn touch<A>(_a: &A) {}

src/test/compile-fail/non-exhaustive-match.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
enum t { a, b, }
1214

1315
fn main() {

src/test/compile-fail/occurs-check.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
fn main() {
1214
let f; //~ ERROR cyclic type of infinite size
1315
f = @f;

src/test/compile-fail/static-region-bound.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#[feature(managed_boxes)];
2+
13
fn f<T:'static>(_: T) {}
24

35
fn main() {

src/test/compile-fail/unique-unique-kind.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
fn f<T:Send>(_i: T) {
1214
}
1315

src/test/run-fail/borrowck-wg-autoderef-and-autoborrowvec-combined-fail-issue-6272.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//
99
// for a detailed explanation of what is going on here.
1010

11+
#[feature(managed_boxes)];
12+
1113
fn main() {
1214
let a = @mut [3i];
1315
let b = @mut [a];

src/test/run-fail/borrowck-wg-fail-2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Test that write guards trigger when there is a write to a field
44
// of a frozen structure.
55

6+
#[feature(managed_boxes)];
7+
68
struct S {
79
x: int
810
}

src/test/run-fail/borrowck-wg-fail-3.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Test that write guards trigger when there is a write to a directly
44
// frozen @mut box.
55

6+
#[feature(managed_boxes)];
7+
68
fn main() {
79
let x = @mut 3;
810
let _y: &mut int = x;

src/test/run-fail/borrowck-wg-one-mut-one-imm-slice-method.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Test that write guards trigger when there is a coercion to
44
// a slice on the receiver of a method.
55

6+
#[feature(managed_boxes)];
7+
68
trait MyMutSlice {
79
fn my_mut_slice(self) -> Self;
810
}

src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
// Test that write guards trigger when arguments are coerced to slices.
44

5+
#[feature(managed_boxes)];
6+
57
fn add(x:&mut [int], y:&[int])
68
{
79
x[0] = x[0] + y[0];

src/test/run-fail/borrowck-wg-one-mut-one-imm.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Test that write guards trigger when we are indexing into
44
// an @mut vector.
55

6+
#[feature(managed_boxes)];
7+
68
fn add(x:&mut int, y:&int)
79
{
810
*x = *x + *y;

src/test/run-fail/borrowck-wg-two-array-indices.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Test that arguments trigger when there are *two mutable* borrows
44
// of indices.
55

6+
#[feature(managed_boxes)];
7+
68
fn add(x:&mut int, y:&mut int)
79
{
810
*x = *x + *y;

src/test/run-fail/unwind-assert.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn main() {
1416
let _a = @0;
1517
assert!(false);

src/test/run-fail/unwind-box-res.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
use std::cast;
1416

1517
fn failfn() {

src/test/run-fail/unwind-box-str.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn failfn() {
1416
fail!();
1517
}

src/test/run-fail/unwind-box-unique-unique.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn failfn() {
1416
fail!();
1517
}

src/test/run-fail/unwind-box-unique.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn failfn() {
1416
fail!();
1517
}

src/test/run-fail/unwind-box-vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn failfn() {
1416
fail!();
1517
}

src/test/run-fail/unwind-box.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn failfn() {
1416
fail!();
1517
}

src/test/run-fail/unwind-fail.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn main() {
1416
@0;
1517
fail!();

src/test/run-fail/unwind-iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
1314
#[allow(unreachable_code)];
1415
#[allow(unused_variable)];
1516

src/test/run-fail/unwind-iter2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn x(it: |int|) {
1416
let _a = @0;
1517
it(1);

src/test/run-fail/unwind-match.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
// Issue #945
1214
// error-pattern:non-exhaustive match failure
1315
fn test_box() {

src/test/run-fail/unwind-misc-1.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// exec-env:RUST_NEWRT=1
1212
// error-pattern:fail
1313

14+
#[feature(managed_boxes)];
15+
1416
fn main() {
1517
let _count = @mut 0u;
1618
let mut map = std::hashmap::HashMap::new();

src/test/run-fail/unwind-nested.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn main() {
1416
let _a = @0;
1517
{

src/test/run-fail/unwind-partial-box.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn f() -> ~[int] { fail!(); }
1416

1517
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might

src/test/run-fail/unwind-partial-unique.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn f() -> ~[int] { fail!(); }
1416

1517
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might

src/test/run-fail/unwind-partial-vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn f() -> ~[int] { fail!(); }
1416

1517
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might

src/test/run-fail/unwind-stacked.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn f() {
1416
let _a = @0;
1517
fail!();

src/test/run-fail/unwind-uninitialized.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// error-pattern:fail
1212

13+
#[feature(managed_boxes)];
14+
1315
fn f() {
1416
fail!();
1517
}

src/test/run-pass/auto-ref-slice-plus-ref.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// Testing that method lookup automatically both borrows vectors to slices
1212
// and also references them to create the &self pointer
1313

14+
#[feature(managed_boxes)];
15+
1416
trait MyIter {
1517
fn test_imm(&self);
1618
}

src/test/run-pass/autoderef-method-twice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
trait double {
1214
fn double(@self) -> uint;
1315
}

src/test/run-pass/autoderef-method.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
trait double {
1214
fn double(@self) -> uint;
1315
}

src/test/run-pass/borrowck-borrow-from-at-vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[feature(managed_boxes)];
12+
1113
fn sum_slice(x: &[int]) -> int {
1214
let mut sum = 0;
1315
for i in x.iter() { sum += *i; }

0 commit comments

Comments
 (0)