1 // Copyright 2013 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.
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.
12 #![allow(unused_variable)]
13 #![allow(non_camel_case_types)]
14 #![allow(visible_private_types)]
16 #![feature(lang_items)]
26 pub struct Bar; //~ ERROR: code is never used
33 pub static pub_static: int = 0;
34 static priv_static: int = 0; //~ ERROR: code is never used
35 static used_static: int = 0;
36 pub static used_static2: int = used_static;
37 static USED_STATIC: int = 0;
38 static STATIC_USED_IN_ENUM_DISCRIMINANT: uint = 10;
40 pub type typ = *UsedStruct4;
42 struct PrivStruct; //~ ERROR: code is never used
47 struct UsedStruct2(int);
50 // this struct is never used directly, but its method is, so we don't want
52 struct SemiUsedStruct;
56 struct StructUsedAsField;
57 struct StructUsedInEnum;
58 struct StructUsedInGeneric;
59 pub struct PubStruct2 {
61 struct_used_as_field: *StructUsedAsField
64 pub enum pub_enum { foo1, bar1 }
65 pub enum pub_enum2 { a(*StructUsedInEnum) }
66 pub enum pub_enum3 { Foo = STATIC_USED_IN_ENUM_DISCRIMINANT }
67 enum priv_enum { foo2, bar2 } //~ ERROR: code is never used
68 enum used_enum { foo3, bar3 }
74 let used_struct1 = UsedStruct1 { x: 1 };
75 let used_struct2 = UsedStruct2(1);
76 let used_struct3 = UsedStruct3;
78 SemiUsedStruct::la_la_la();
85 f::<StructUsedInGeneric>();
87 fn priv_fn() { //~ ERROR: code is never used
88 let unused_struct = PrivStruct;
92 fn foo() { //~ ERROR: code is never used
94 let unused_enum = foo2;
97 fn bar() { //~ ERROR: code is never used
101 // Code with #[allow(dead_code)] should be marked live (and thus anything it
102 // calls is marked live)
107 // Similarly, lang items are live
109 fn fail(_: *u8, _: *u8, _: uint) -> ! { loop {} }