Skip to content

Suggestion in warning for extern function pointers broken #52345

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
gnzlbg opened this issue Jul 13, 2018 · 0 comments · Fixed by #52346
Closed

Suggestion in warning for extern function pointers broken #52345

gnzlbg opened this issue Jul 13, 2018 · 0 comments · Fixed by #52346

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 13, 2018

https://play.rust-lang.org/?gist=d8a933822fb81608431b4001e6bae154&version=stable&mode=debug&edition=2015

Given this

#![crate_type = "rlib"]

extern "C" {
    pub static mut foo: fn()->(); // WARNS
    //pub static mut bar: fn "extern"()->(); // ERRORS
    pub static mut baz: extern fn()->(); // OK
}

the warning on foo is:

|
4 |     pub static mut foo: fn()->(); // WARNS
  |                         ^^^^^^^^
  |
  = note: #[warn(improper_ctypes)] on by default
  = help: consider using an `fn "extern"(...) -> ...` function pointer instead

The code suggested does not work though, it should be extern fn(...) -> ... instead.

hanna-kruppe pushed a commit to hanna-kruppe/rust that referenced this issue Jul 13, 2018
kennytm added a commit to kennytm/rust that referenced this issue Jul 13, 2018
Fix typo in improper_ctypes suggestion

closes rust-lang#52345
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

Successfully merging a pull request may close this issue.

1 participant