asomers / mockall

A powerful mock object library for Rust
Apache License 2.0
1.5k stars 62 forks source link

automock should strip `#[link_name = "..."]` #502

Closed corecode closed 1 year ago

corecode commented 1 year ago

Building mocks for bindgen output for inline static functions results in:

warning: attribute should be applied to a foreign function or static
     --> bindings.rs:58960:5
      |
57180 | #[mockall::automock]
      | -------------------- not a foreign function or static
...
58960 |     #[link_name = "FooName__extern"]
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
asomers commented 1 year ago

Interesting. Can you share more of the source? Or better yet, a complete example?

corecode commented 1 year ago

the fragment in question is generated code like this:

extern "C" {
    #[doc = "blablabla"]
    #[link_name = "SystemCoreClockGet__extern"]
    pub fn SystemCoreClockGet() -> u32;
}

which is wrapped in an #[automock] mod functions { ... }