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_variables)]
13 #![allow(non_camel_case_types)]
14 #![allow(non_upper_case_globals)]
15 #![allow(missing_copy_implementations)]
25 pub struct Bar; //~ ERROR: struct is never used
32 pub static pub_static: int = 0;
33 static priv_static: int = 0; //~ ERROR: static item is never used
34 const used_static: int = 0;
35 pub static used_static2: int = used_static;
36 const USED_STATIC: int = 0;
37 const STATIC_USED_IN_ENUM_DISCRIMINANT: int = 10;
39 pub const pub_const: int = 0;
40 const priv_const: int = 0; //~ ERROR: constant item is never used
41 const used_const: int = 0;
42 pub const used_const2: int = used_const;
43 const USED_CONST: int = 1;
44 const CONST_USED_IN_ENUM_DISCRIMINANT: int = 11;
46 pub type typ = *const UsedStruct4;
48 struct PrivStruct; //~ ERROR: struct is never used
53 struct UsedStruct2(int);
56 // this struct is never used directly, but its method is, so we don't want
58 struct SemiUsedStruct;
62 struct StructUsedAsField;
63 pub struct StructUsedInEnum;
64 struct StructUsedInGeneric;
65 pub struct PubStruct2 {
67 struct_used_as_field: *const StructUsedAsField
70 pub enum pub_enum { foo1, bar1 }
71 pub enum pub_enum2 { a(*const StructUsedInEnum) }
73 Foo = STATIC_USED_IN_ENUM_DISCRIMINANT,
74 Bar = CONST_USED_IN_ENUM_DISCRIMINANT,
77 enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used
80 bar3 //~ ERROR variant is never used
87 let used_struct1 = UsedStruct1 { x: 1 };
88 let used_struct2 = UsedStruct2(1);
89 let used_struct3 = UsedStruct3;
90 let e = used_enum::foo3;
91 SemiUsedStruct::la_la_la();
99 f::<StructUsedInGeneric>();
101 fn priv_fn() { //~ ERROR: function is never used
102 let unused_struct = PrivStruct;
106 fn foo() { //~ ERROR: function is never used
108 let unused_enum = priv_enum::foo2;
111 fn bar() { //~ ERROR: function is never used
115 // Code with #[allow(dead_code)] should be marked live (and thus anything it
116 // calls is marked live)