Skip to content

Suggestion in warning for extern function pointers broken #52345

Closed
@gnzlbg

Description

@gnzlbg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions