diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-01-19 15:10:34 +0100 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-02-27 09:24:16 +0100 |
| commit | 4cb3bd558f64bac0964fc9b3e342fe20c30ded40 (patch) | |
| tree | b0f99b4cb56284c646254c98dbd6e72961603608 /src | |
| parent | 68a92c5ed58e676d6aa224681080f921b9e069a5 (diff) | |
| download | rust-4cb3bd558f64bac0964fc9b3e342fe20c30ded40.tar.gz rust-4cb3bd558f64bac0964fc9b3e342fe20c30ded40.zip | |
Remove unused type_is_pod function
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/ty.rs | 55 | ||||
| -rw-r--r-- | src/test/compile-fail/static-items-cant-move.rs | 29 |
2 files changed, 29 insertions, 55 deletions
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 6db83ff32b6..a85d21f2ef7 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2624,61 +2624,6 @@ pub fn type_is_machine(ty: t) -> bool { } } -// Whether a type is Plain Old Data -- meaning it does not contain pointers -// that the cycle collector might care about. -pub fn type_is_pod(cx: ctxt, ty: t) -> bool { - let mut result = true; - match get(ty).sty { - // Scalar types - ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) | - ty_ptr(_) | ty_bare_fn(_) => result = true, - // Boxed types - ty_box(_) | ty_uniq(_) | ty_closure(_) | - ty_str(vstore_uniq) | - ty_vec(_, vstore_uniq) | - ty_trait(_, _, _, _, _) | ty_rptr(_,_) => result = false, - // Structural types - ty_enum(did, ref substs) => { - let variants = enum_variants(cx, did); - for variant in (*variants).iter() { - // FIXME(pcwalton): This is an inefficient way to do this. Don't - // synthesize a tuple! - // - // Perform any type parameter substitutions. - let tup_ty = mk_tup(cx, variant.args.clone()); - let tup_ty = subst(cx, substs, tup_ty); - if !type_is_pod(cx, tup_ty) { result = false; } - } - } - ty_tup(ref elts) => { - for elt in elts.iter() { if !type_is_pod(cx, *elt) { result = false; } } - } - ty_str(vstore_fixed(_)) => result = true, - ty_vec(ref mt, vstore_fixed(_)) | ty_unboxed_vec(ref mt) => { - result = type_is_pod(cx, mt.ty); - } - ty_param(_) => result = false, - ty_struct(did, ref substs) => { - let fields = lookup_struct_fields(cx, did); - result = fields.iter().all(|f| { - let fty = ty::lookup_item_type(cx, f.id); - let sty = subst(cx, substs, fty.ty); - type_is_pod(cx, sty) - }); - } - - ty_str(vstore_slice(..)) | ty_vec(_, vstore_slice(..)) => { - result = false; - } - - ty_infer(..) | ty_self(..) | ty_err => { - cx.sess.bug("non concrete type in type_is_pod"); - } - } - - return result; -} - pub fn type_is_enum(ty: t) -> bool { match get(ty).sty { ty_enum(_, _) => return true, diff --git a/src/test/compile-fail/static-items-cant-move.rs b/src/test/compile-fail/static-items-cant-move.rs new file mode 100644 index 00000000000..1bd78d2b1a2 --- /dev/null +++ b/src/test/compile-fail/static-items-cant-move.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Verifies that static items can't be moved + +use std::kinds::marker; + +struct Foo { + foo: int, + nopod: marker::NoPod +} + +static BAR: Foo = Foo{foo: 5, nopod: marker::NoPod}; + + +fn test(f: Foo) { + let _f = Foo{foo: 4, ..f}; +} + +fn main() { + test(BAR); +} |
