Skip to content

The start function should always be recognized as reachable, even with --crate-type=dylib #14034

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
zwarich opened this issue May 8, 2014 · 2 comments

Comments

@zwarich
Copy link

zwarich commented May 8, 2014

Running rustc --crate-type=dylib test.rs on

#[start]
fn start(_argc: int, _argv: **u8) -> int { 0 }

gives the warning

test.rs:2:1: 2:47 warning: code is never used: `start`, #[warn(dead_code)] on by default
test.rs:2 fn start(_argc: int, _argv: **u8) -> int { 0 }
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

despite the start function being generated and exported. Servo hits this warning in src/components/main/servo.rs.

@alexcrichton
Copy link
Member

If you're building a library, the compiler doesn't use #[start] at all, so this seems like it's an accurate warning?

@zwarich
Copy link
Author

zwarich commented May 8, 2014

I was just confused by Servo's workaround for #13905, which involves building the same .rs file with two different crate types, and thought that the dylib also contained the start function.

@zwarich zwarich closed this as completed May 8, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 28, 2025
fix rust-lang#14034

The currect implementation of `obfuscated_if_else` sometimes makes
incorrect suggestions when the original code have side effects (see the
example in the above issue). I think this can be fixed by changing the
applicability depending on whether it can have side effects or not.

changelog: [`obfuscated_if_else`]: change applicability when the
original code can have side effects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants