1
Fork 0

Handle more cases in the heap lints

This commit is contained in:
Alex Crichton 2013-12-12 00:02:26 -08:00
parent 0f6537fed4
commit 6747d0738a
18 changed files with 54 additions and 5 deletions

View file

@ -770,9 +770,21 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
let mut n_uniq = 0; let mut n_uniq = 0;
ty::fold_ty(cx.tcx, ty, |t| { ty::fold_ty(cx.tcx, ty, |t| {
match ty::get(t).sty { match ty::get(t).sty {
ty::ty_box(_) => n_box += 1, ty::ty_box(_) | ty::ty_estr(ty::vstore_box) |
ty::ty_uniq(_) => n_uniq += 1, ty::ty_evec(_, ty::vstore_box) |
_ => () ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
n_box += 1;
}
ty::ty_uniq(_) | ty::ty_estr(ty::vstore_uniq) |
ty::ty_evec(_, ty::vstore_uniq) |
ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => {
n_uniq += 1;
}
ty::ty_closure(ref c) if c.sigil == ast::OwnedSigil => {
n_uniq += 1;
}
_ => ()
}; };
t t
}); });

View file

@ -19,6 +19,20 @@ struct Foo {
struct Bar { x: ~int } //~ ERROR type uses owned struct Bar { x: ~int } //~ ERROR type uses owned
fn main() { fn main() {
let _x : Bar = Bar {x : ~10}; let _x : Bar = Bar {x : ~10}; //~ ERROR type uses owned
@2; //~ ERROR type uses managed
@[1]; //~ ERROR type uses managed
//~^ ERROR type uses managed
fn f(_: @Clone) {} //~ ERROR type uses managed
@""; //~ ERROR type uses managed
//~^ ERROR type uses managed
~2; //~ ERROR type uses owned
~[1]; //~ ERROR type uses owned
//~^ ERROR type uses owned //~^ ERROR type uses owned
fn g(_: ~Clone) {} //~ ERROR type uses owned
~""; //~ ERROR type uses owned
//~^ ERROR type uses owned
proc() {}; //~ ERROR type uses owned
} }

View file

@ -43,6 +43,7 @@
// debugger:print *unique_val_interior_ref_2 // debugger:print *unique_val_interior_ref_2
// check:$10 = 26.5 // check:$10 = 26.5
#[feature(managed_boxes)];
#[allow(unused_variable)]; #[allow(unused_variable)];
struct SomeStruct { struct SomeStruct {

View file

@ -22,6 +22,7 @@
// debugger:print d->val // debugger:print d->val
// check:$4 = false // check:$4 = false
#[feature(managed_boxes)];
#[allow(unused_variable)]; #[allow(unused_variable)];
fn main() { fn main() {

View file

@ -25,6 +25,7 @@
// debugger:print managed_dtor->val // debugger:print managed_dtor->val
// check:$4 = {x = 33, y = 333, z = 3333, w = 33333} // check:$4 = {x = 33, y = 333, z = 3333, w = 33333}
#[feature(managed_boxes)];
#[allow(unused_variable)]; #[allow(unused_variable)];
struct StructWithSomePadding { struct StructWithSomePadding {

View file

@ -123,6 +123,7 @@
// debugger:print *nn // debugger:print *nn
// check:$43 = 56 // check:$43 = 56
#[feature(managed_boxes)];
#[allow(unused_variable)]; #[allow(unused_variable)];
struct Struct { struct Struct {

View file

@ -94,6 +94,8 @@
// check:$21 = {-16, 16.5} // check:$21 = {-16, 16.5}
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct Struct<T> { struct Struct<T> {
x: T x: T
} }

View file

@ -23,7 +23,7 @@
// check:$3 = {-9747455} // check:$3 = {-9747455}
#[allow(unused_variable)]; #[allow(unused_variable)];
#[feature(struct_variant)]; #[feature(struct_variant, managed_boxes)];
// The first element is to ensure proper alignment, irrespective of the machines word size. Since // The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when // the size of the discriminant value is machine dependent, this has be taken into account when

View file

@ -94,6 +94,7 @@
// check:$21 = -16 // check:$21 = -16
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
#[feature(struct_variant)]; #[feature(struct_variant)];
enum Enum { enum Enum {

View file

@ -94,6 +94,8 @@
// check:$21 = -16 // check:$21 = -16
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct Struct<T> { struct Struct<T> {
x: T x: T
} }

View file

@ -94,6 +94,8 @@
// check:$21 = -16 // check:$21 = -16
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct Struct { struct Struct {
x: int x: int
} }

View file

@ -94,6 +94,8 @@
// check:$21 = -16 // check:$21 = -16
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct Struct { struct Struct {
x: int x: int
} }

View file

@ -94,6 +94,8 @@
// check:$21 = -16 // check:$21 = -16
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct TupleStruct(int, f64); struct TupleStruct(int, f64);
impl TupleStruct { impl TupleStruct {

View file

@ -94,6 +94,8 @@
// check:$21 = -16 // check:$21 = -16
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct Struct { struct Struct {
x: int x: int
} }

View file

@ -94,6 +94,8 @@
// check:$21 = {-16, 16.5} // check:$21 = {-16, 16.5}
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
struct Struct { struct Struct {
x: int x: int
} }

View file

@ -49,6 +49,7 @@
// check:$14 = 8 // check:$14 = 8
// debugger:continue // debugger:continue
#[feature(managed_boxes)];
#[allow(unused_variable)]; #[allow(unused_variable)];
struct Struct { struct Struct {

View file

@ -28,6 +28,7 @@
// debugger:print managed->val // debugger:print managed->val
// check:$6 = 7 // check:$6 = 7
#[feature(managed_boxes)];
#[allow(unused_variable)]; #[allow(unused_variable)];
struct Struct { struct Struct {

View file

@ -12,6 +12,8 @@
// previously ambiguous (e.g. 'if true { } *val;' gets parsed as a // previously ambiguous (e.g. 'if true { } *val;' gets parsed as a
// binop) // binop)
#[feature(managed_boxes)];
fn test1() { let val = @0; { } *val; } fn test1() { let val = @0; { } *val; }
fn test2() -> int { let val = @0; { } *val } fn test2() -> int { let val = @0; { } *val }