Skip to content

Inconsistent behavior between check and build when handling duplicate #[no_mangle] static values #63362

@zack-emmert

Description

@zack-emmert

(if this issue is better suited to rust-lang/rust, please let me know and I'll post it there)

Problem
cargo check and cargo build behave differently when handling two identically-named #[no_mangle] static values defined in different modules. cargo check incorrectly succeeds without detecting any issues, while cargo build correctly throws a "symbol has already been defined" error.

Steps

  1. Copy the snippet below these instructions into a new project
  2. Execute cargo check, observe incorrect success
  3. Execute cargo build, observe correct compiler error
mod other {
    #[no_mangle]
    pub static ITSBROKEN: u8 = 0;
}

#[no_mangle]
pub static ITSBROKEN: u8 = 0;

Notes

Output of cargo version: cargo 1.36.0 (c4fcfb725 2019-05-15)
Target: x86_64-unknown-linux-gnu
Linux distribution: Fedora 30 (fully updated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metadataArea: Crate metadataT-cargoRelevant to the cargo team, which will review and decide on the PR/issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions