Skip to content

#[link] not before extern is silently ignored #13695

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
kornelski opened this issue Apr 23, 2014 · 2 comments
Closed

#[link] not before extern is silently ignored #13695

kornelski opened this issue Apr 23, 2014 · 2 comments

Comments

@kornelski
Copy link
Contributor

#[link(name="bad")]
fn main() {
}

compiles without warnings. I would expect warning that the link is unused or in the wrong place.

This causes a gotcha: if you insert any code between link and extern you suddenly get linker errors, because there's no -llibrary flag added.

#[link(name="library")]

struct SURPRISE();

extern {
    pub fn library() -> ();
}

fn main() {
    unsafe {
        library();
    }
}

I've got bitten by this when I've moved #[link] next to extern crate and #![crate_id] statements that I thought it belongs with.

@sfackler
Copy link
Member

This should be fixed by RFC #2 whenever it gets implemented.

@steveklabnik
Copy link
Member

Yup!

arcnmx pushed a commit to arcnmx/rust that referenced this issue Dec 17, 2022
Update Chalk to version 87

Changes:
- Support new `tuple_trait` lang item ([chalk#782](rust-lang/chalk#782))
- Removed empty lifetime ([chalk#783](rust-lang/chalk#783))
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 28, 2024
…3695)

Close rust-lang#13679

changelog: [`if_let_mutex`]: disable lint from Edition 2024 since
[stabilized if_let_rescope
](rust-lang#131154)
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

3 participants