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