Skip to content

Overeager warning for clashing external declarations in different wasm import modules #79581

Closed
@pchickey

Description

@pchickey

Rustc 1.48.0 gives an incorrect warning about an external symbol being redeclared with a different signature, when the external symbols are in different wasm_import_module namespaces.

I tried this code:

pub mod a {
    #[link(wasm_import_module = "a")]
    extern "C" {
        pub fn foo();
    }
}

pub mod b {
    #[link(wasm_import_module = "b")]
    extern "C" {
        pub fn foo() -> usize;
    }
}

I expected to see this happen: Compile without warnings

Instead, this happened:

warning: `foo` redeclared with a different signature
  --> src/lib.rs:11:9
   |
4  |         pub fn foo();
   |         ------------- `foo` previously declared here
...
11 |         pub fn foo() -> usize;
   |         ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
   |
   = note: `#[warn(clashing_extern_declarations)]` on by default
   = note: expected `unsafe extern "C" fn()`
              found `unsafe extern "C" fn() -> usize`

Meta

rustc --version --verbose:

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0

The same behavior exists on nightly as well:

rustc 1.50.0-nightly (825637983 2020-11-18)
binary: rustc
commit-hash: 8256379832b5ecb7f71e8c5e2018446482223c12
commit-date: 2020-11-18
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
Backtrace

<backtrace>

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions