Mark allowed dead code and lang items as live

Dead code pass now explicitly checks for `#[allow(dead_code)]` and
`#[lang=".."]` attributes on items and marks them as live if they have
those attributes. The former is done so that if we want to suppress
warnings for a group of dead functions, we only have to annotate the
"root" of the call chain.
This commit is contained in:
Kiet Tran 2014-01-11 03:21:53 -05:00
parent 1fda761e9c
commit deb3ca53a8
3 changed files with 80 additions and 13 deletions

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[no_std];
#[allow(unused_variable)];
#[deny(dead_code)];
@ -85,3 +86,13 @@ fn foo() { //~ ERROR: code is never used
fn bar() { //~ ERROR: code is never used
foo();
}
// Code with #[allow(dead_code)] should be marked live (and thus anything it
// calls is marked live)
#[allow(dead_code)]
fn g() { h(); }
fn h() {}
// Similarly, lang items are live
#[lang="fail_"]
fn fail(_: *u8, _: *u8, _: uint) -> ! { loop {} }