rust/tests/ui/lint/dead-code/lint-dead-code-2.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
509 B
Rust
Raw Normal View History

2014-10-27 22:37:07 +00:00
#![allow(unused_variables)]
#![deny(dead_code)]
#![feature(rustc_attrs)]
2013-12-08 07:55:27 +00:00
struct Foo;
trait Bar {
fn bar1(&self);
fn bar2(&self) {
self.bar1();
}
}
impl Bar for Foo {
fn bar1(&self) {
live_fn();
}
}
fn live_fn() {}
fn dead_fn() {} //~ ERROR: function `dead_fn` is never used
2013-12-08 07:55:27 +00:00
fn used_fn() {}
#[rustc_main]
fn actual_main() {
2013-12-08 07:55:27 +00:00
used_fn();
let foo = Foo;
foo.bar2();
}
// this is not main
fn main() { //~ ERROR: function `main` is never used
2013-12-08 07:55:27 +00:00
dead_fn();
}