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)]
22 pub struct Bar
; //~ ERROR: struct is never used
29 pub static pub_static
: isize = 0;
30 static priv_static
: isize = 0; //~ ERROR: static item is never used
31 const used_static
: isize = 0;
32 pub static used_static2
: isize = used_static
;
33 const USED_STATIC
: isize = 0;
34 const STATIC_USED_IN_ENUM_DISCRIMINANT
: isize = 10;
36 pub const pub_const
: isize = 0;
37 const priv_const
: isize = 0; //~ ERROR: constant item is never used
38 const used_const
: isize = 0;
39 pub const used_const2
: isize = used_const
;
40 const USED_CONST
: isize = 1;
41 const CONST_USED_IN_ENUM_DISCRIMINANT
: isize = 11;
43 pub type typ
= *const UsedStruct4
;
45 struct PrivStruct
; //~ ERROR: struct is never used
50 struct UsedStruct2(isize);
52 pub struct UsedStruct4
;
53 // this struct is never used directly, but its method is, so we don't want
55 struct SemiUsedStruct
;
59 struct StructUsedAsField
;
60 pub struct StructUsedInEnum
;
61 struct StructUsedInGeneric
;
62 pub struct PubStruct2
{
64 struct_used_as_field
: *const StructUsedAsField
67 pub enum pub_enum { foo1, bar1 }
68 pub enum pub_enum2 { a(*const StructUsedInEnum) }
70 Foo
= STATIC_USED_IN_ENUM_DISCRIMINANT
,
71 Bar
= CONST_USED_IN_ENUM_DISCRIMINANT
,
74 enum priv_enum { foo2, bar2 }
//~ ERROR: enum is never used
77 bar3
//~ ERROR variant is never used
84 let used_struct1
= UsedStruct1 { x: 1 }
;
85 let used_struct2
= UsedStruct2(1);
86 let used_struct3
= UsedStruct3
;
87 let e
= used_enum
::foo3
;
88 SemiUsedStruct
::la_la_la();
96 f
::<StructUsedInGeneric
>();
98 fn priv_fn() { //~ ERROR: function is never used
99 let unused_struct
= PrivStruct
;
103 fn foo() { //~ ERROR: function is never used
105 let unused_enum
= priv_enum
::foo2
;
108 fn bar() { //~ ERROR: function is never used
112 // Code with #[allow(dead_code)] should be marked live (and thus anything it
113 // calls is marked live)