Skip to content

Commit 4cb3bd5

Browse files
committed
Remove unused type_is_pod function
1 parent 68a92c5 commit 4cb3bd5

File tree

2 files changed

+29
-55
lines changed

2 files changed

+29
-55
lines changed

src/librustc/middle/ty.rs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,61 +2624,6 @@ pub fn type_is_machine(ty: t) -> bool {
26242624
}
26252625
}
26262626

2627-
// Whether a type is Plain Old Data -- meaning it does not contain pointers
2628-
// that the cycle collector might care about.
2629-
pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
2630-
let mut result = true;
2631-
match get(ty).sty {
2632-
// Scalar types
2633-
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
2634-
ty_ptr(_) | ty_bare_fn(_) => result = true,
2635-
// Boxed types
2636-
ty_box(_) | ty_uniq(_) | ty_closure(_) |
2637-
ty_str(vstore_uniq) |
2638-
ty_vec(_, vstore_uniq) |
2639-
ty_trait(_, _, _, _, _) | ty_rptr(_,_) => result = false,
2640-
// Structural types
2641-
ty_enum(did, ref substs) => {
2642-
let variants = enum_variants(cx, did);
2643-
for variant in (*variants).iter() {
2644-
// FIXME(pcwalton): This is an inefficient way to do this. Don't
2645-
// synthesize a tuple!
2646-
//
2647-
// Perform any type parameter substitutions.
2648-
let tup_ty = mk_tup(cx, variant.args.clone());
2649-
let tup_ty = subst(cx, substs, tup_ty);
2650-
if !type_is_pod(cx, tup_ty) { result = false; }
2651-
}
2652-
}
2653-
ty_tup(ref elts) => {
2654-
for elt in elts.iter() { if !type_is_pod(cx, *elt) { result = false; } }
2655-
}
2656-
ty_str(vstore_fixed(_)) => result = true,
2657-
ty_vec(ref mt, vstore_fixed(_)) | ty_unboxed_vec(ref mt) => {
2658-
result = type_is_pod(cx, mt.ty);
2659-
}
2660-
ty_param(_) => result = false,
2661-
ty_struct(did, ref substs) => {
2662-
let fields = lookup_struct_fields(cx, did);
2663-
result = fields.iter().all(|f| {
2664-
let fty = ty::lookup_item_type(cx, f.id);
2665-
let sty = subst(cx, substs, fty.ty);
2666-
type_is_pod(cx, sty)
2667-
});
2668-
}
2669-
2670-
ty_str(vstore_slice(..)) | ty_vec(_, vstore_slice(..)) => {
2671-
result = false;
2672-
}
2673-
2674-
ty_infer(..) | ty_self(..) | ty_err => {
2675-
cx.sess.bug("non concrete type in type_is_pod");
2676-
}
2677-
}
2678-
2679-
return result;
2680-
}
2681-
26822627
pub fn type_is_enum(ty: t) -> bool {
26832628
match get(ty).sty {
26842629
ty_enum(_, _) => return true,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Verifies that static items can't be moved
12+
13+
use std::kinds::marker;
14+
15+
struct Foo {
16+
foo: int,
17+
nopod: marker::NoPod
18+
}
19+
20+
static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod};
21+
22+
23+
fn test(f: Foo) {
24+
let _f = Foo{foo: 4, ..f};
25+
}
26+
27+
fn main() {
28+
test(BAR);
29+
}

0 commit comments

Comments
 (0)