Skip to content

Dead code should consider lang items live #11440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
huonw opened this issue Jan 10, 2014 · 0 comments
Closed

Dead code should consider lang items live #11440

huonw opened this issue Jan 10, 2014 · 0 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@huonw
Copy link
Member

huonw commented Jan 10, 2014

They don't get used in the AST directly, so the dead code lint can't detect them.

#[no_std];
#[no_main];

#[no_mangle]
pub fn main(_: i32, _: **u8) -> i32 {
    1 / 1
}

#[lang="fail_"]
fn fail(_: *u8, _: *u8, _: uint) -> ! { loop {} }
$ rustc lang-dead.rs
lang-dead.rs:10:1: 10:50 warning: code is never used: `fail`, #[warn(dead_code)] on by default
lang-dead.rs:10 fn fail(_: *u8, _: *u8, _: uint) -> ! { loop {} }
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[... linking errors ...]
bors added a commit that referenced this issue Jan 12, 2014
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.

Close #11380 and #11440.
@sanxiyn sanxiyn closed this as completed Jan 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

2 participants