Skip to content

Cargo check does not report error: symbol foo is already defined #61330

Closed
@mcarton

Description

@mcarton

Problem
Some errors are not reported by cargo check.

Steps
For example, here cargo check succeeds:

% cargo check
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
% cat src/main.rs 
#[no_mangle]
fn test() {}

mod foo {
    #[no_mangle]
    fn test() {}
}

fn main() {
    println!("Hello, world!");
}

But cargo build does fail:

% cargo build
   Compiling asdf v0.1.0 (/tmp/asdf)
error: symbol `test` is already defined
 --> src/main.rs:6:5
  |
6 |     fn test() {}
  |     ^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `asdf`.

To learn more, run the command again with --verbose.

Notes

Output of cargo version:

% cargo --version      
cargo 1.34.0 (6789d8a0a 2019-04-01)
% rustc --version
rustc 1.34.2 (6c2484dc3 2019-05-13)
% rustup --version
rustup 1.18.1 (2019-04-26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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