Skip to content

Commit 6747d07

Browse files
committed
Handle more cases in the heap lints
1 parent 0f6537f commit 6747d07

18 files changed

+54
-5
lines changed

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

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

46+
#[feature(managed_boxes)];
4647
#[allow(unused_variable)];
4748

4849
struct SomeStruct {

src/test/debug-info/box.rs

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

25+
#[feature(managed_boxes)];
2526
#[allow(unused_variable)];
2627

2728
fn main() {

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

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

28+
#[feature(managed_boxes)];
2829
#[allow(unused_variable)];
2930

3031
struct StructWithSomePadding {

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

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

126+
#[feature(managed_boxes)];
126127
#[allow(unused_variable)];
127128

128129
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
@@ -23,7 +23,7 @@
2323
// check:$3 = {-9747455}
2424

2525
#[allow(unused_variable)];
26-
#[feature(struct_variant)];
26+
#[feature(struct_variant, managed_boxes)];
2727

2828
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
2929
// 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 }

0 commit comments

Comments
 (0)