]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/lint-dead-code-2.rs
Convert most code to new inner attribute syntax.
[rust.git] / src / test / compile-fail / lint-dead-code-2.rs
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.
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 #![allow(unused_variable)]
12 #![deny(dead_code)]
13
14 struct Foo;
15
16 trait Bar {
17     fn bar1(&self);
18     fn bar2(&self) {
19         self.bar1();
20     }
21 }
22
23 impl Bar for Foo {
24     fn bar1(&self) {
25         live_fn();
26     }
27 }
28
29 fn live_fn() {}
30
31 fn dead_fn() {} //~ ERROR: code is never used
32
33 #[main]
34 fn dead_fn2() {} //~ ERROR: code is never used
35
36 fn used_fn() {}
37
38 #[start]
39 fn start(_: int, _: **u8) -> int {
40     used_fn();
41     let foo = Foo;
42     foo.bar2();
43     0
44 }
45
46 // this is not main
47 fn main() { //~ ERROR: code is never used
48     dead_fn();
49     dead_fn2();
50 }