Skip to content

dead_code fails to consider reexports of foreign items #15740

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 Jul 17, 2014 · 2 comments
Closed

dead_code fails to consider reexports of foreign items #15740

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

Comments

@huonw
Copy link
Member

huonw commented Jul 17, 2014

#![crate_type = "lib"]
pub use x = foo;
extern { fn foo(); }

playpen

<anon>:3:10: 3:19 warning: code is never used: `foo`, #[warn(dead_code)] on by default
<anon>:3 extern { fn foo(); }
                  ^~~~~~~~~
[...]
@huonw huonw changed the title dead_code fails to consider reexports of foreign functions dead_code fails to consider reexports of foreign items Jul 17, 2014
@ktt3ja
Copy link
Contributor

ktt3ja commented Jul 19, 2014

Is there a reason why foo is not in the exported items set? If it's supposed to be, then changing self.prev_exported && a.vis == ast::Public here to (self.prev_exported && a.vis == ast::Public) || self.reexports.contains(&a.id) would fix this error as well:

if self.prev_exported && a.vis == ast::Public {

@huonw
Copy link
Member Author

huonw commented Jul 20, 2014

// crate_a.rs
#![crate_type = "lib"]
pub use foo = abort;

extern { fn abort() -> !; }
// crate_b.rs
extern crate crate_a;

fn main() {
    unsafe { crate_a::foo(); }
}

Both compile and run fine (i.e. crate_b aborts correctly), so it seems that it's being exported correctly somehow.

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

Successfully merging a pull request may close this issue.

2 participants