Skip to content

Commit 7f5787a

Browse files
committed
auto merge of #10932 : alexcrichton/rust/feature-update, r=cmr
2 parents 8f6df87 + 6747d07 commit 7f5787a

File tree

108 files changed

+241
-21
lines changed

Some content is hidden

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

108 files changed

+241
-21
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/librustc/middle/lint.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,21 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
770770
let mut n_uniq = 0;
771771
ty::fold_ty(cx.tcx, ty, |t| {
772772
match ty::get(t).sty {
773-
ty::ty_box(_) => n_box += 1,
774-
ty::ty_uniq(_) => n_uniq += 1,
775-
_ => ()
773+
ty::ty_box(_) | ty::ty_estr(ty::vstore_box) |
774+
ty::ty_evec(_, ty::vstore_box) |
775+
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
776+
n_box += 1;
777+
}
778+
ty::ty_uniq(_) | ty::ty_estr(ty::vstore_uniq) |
779+
ty::ty_evec(_, ty::vstore_uniq) |
780+
ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => {
781+
n_uniq += 1;
782+
}
783+
ty::ty_closure(ref c) if c.sigil == ast::OwnedSigil => {
784+
n_uniq += 1;
785+
}
786+
787+
_ => ()
776788
};
777789
t
778790
});

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/lint-heap-memory.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ struct Foo {
1919
struct Bar { x: ~int } //~ ERROR type uses owned
2020

2121
fn main() {
22-
let _x : Bar = Bar {x : ~10};
22+
let _x : Bar = Bar {x : ~10}; //~ ERROR type uses owned
23+
24+
@2; //~ ERROR type uses managed
25+
@[1]; //~ ERROR type uses managed
26+
//~^ ERROR type uses managed
27+
fn f(_: @Clone) {} //~ ERROR type uses managed
28+
@""; //~ ERROR type uses managed
29+
//~^ ERROR type uses managed
30+
31+
~2; //~ ERROR type uses owned
32+
~[1]; //~ ERROR type uses owned
33+
//~^ ERROR type uses owned
34+
fn g(_: ~Clone) {} //~ ERROR type uses owned
35+
~""; //~ ERROR type uses owned
2336
//~^ ERROR type uses owned
37+
proc() {}; //~ ERROR type uses owned
2438
}

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/debug-info/borrowed-struct.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
// debugger:print *unique_val_interior_ref_2
4646
// check:$10 = 26.5
4747

48+
#[feature(managed_boxes)];
4849
#[allow(unused_variable)];
4950

5051
struct SomeStruct {

src/test/debug-info/box.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// debugger:print d->val
2525
// check:$4 = false
2626

27+
#[feature(managed_boxes)];
2728
#[allow(unused_variable)];
2829

2930
fn main() {

src/test/debug-info/boxed-struct.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
// debugger:print managed_dtor->val
2828
// check:$4 = {x = 33, y = 333, z = 3333, w = 33333}
2929

30+
#[feature(managed_boxes)];
3031
#[allow(unused_variable)];
3132

3233
struct StructWithSomePadding {

src/test/debug-info/destructured-local.rs

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
// debugger:print *nn
126126
// check:$43 = 56
127127

128+
#[feature(managed_boxes)];
128129
#[allow(unused_variable)];
129130

130131
struct Struct {

src/test/debug-info/generic-method-on-generic-struct.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = {-16, 16.5}
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct Struct<T> {
98100
x: T
99101
}

src/test/debug-info/managed-enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// check:$3 = {-9747455}
2626

2727
#[allow(unused_variable)];
28-
#[feature(struct_variant)];
28+
#[feature(struct_variant, managed_boxes)];
2929

3030
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
3131
// the size of the discriminant value is machine dependent, this has be taken into account when

src/test/debug-info/method-on-enum.rs

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
// check:$21 = -16
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
9798
#[feature(struct_variant)];
9899

99100
enum Enum {

src/test/debug-info/method-on-generic-struct.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = -16
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct Struct<T> {
98100
x: T
99101
}

src/test/debug-info/method-on-struct.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = -16
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct Struct {
98100
x: int
99101
}

src/test/debug-info/method-on-trait.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = -16
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct Struct {
98100
x: int
99101
}

src/test/debug-info/method-on-tuple-struct.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = -16
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct TupleStruct(int, f64);
98100

99101
impl TupleStruct {

src/test/debug-info/self-in-default-method.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = -16
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct Struct {
98100
x: int
99101
}

src/test/debug-info/self-in-generic-default-method.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
// check:$21 = {-16, 16.5}
9595
// debugger:continue
9696

97+
#[feature(managed_boxes)];
98+
9799
struct Struct {
98100
x: int
99101
}

src/test/debug-info/var-captured-in-nested-closure.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
// check:$14 = 8
5050
// debugger:continue
5151

52+
#[feature(managed_boxes)];
5253
#[allow(unused_variable)];
5354

5455
struct Struct {

src/test/debug-info/var-captured-in-stack-closure.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
// debugger:print managed->val
2929
// check:$6 = 7
3030

31+
#[feature(managed_boxes)];
3132
#[allow(unused_variable)];
3233

3334
struct Struct {

src/test/pretty/block-disambig.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// previously ambiguous (e.g. 'if true { } *val;' gets parsed as a
1313
// binop)
1414

15+
#[feature(managed_boxes)];
16+
1517
fn test1() { let val = @0; { } *val; }
1618

1719
fn test2() -> int { let val = @0; { } *val }

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() {

0 commit comments

Comments
 (0)