Skip to content

Unable to find appropriate src/main.rs if it's in src/bin/main.rs #3814

@ehiggs

Description

@ehiggs

According to rust-lang/rust#40185, the following test case should pass:

#[test]
fn run_proper_binary_main_rs() {
    let p = project("foo")
        .file("Cargo.toml", r#"
            [package]
            name = "foo"
            authors = []
            version = "0.0.0"
            [[bin]]
            name = "foo"
        "#)
        .file("src/lib.rs", "")
        .file("src/bin/main.rs", r#"
            fn main() {
            }
        "#);

    assert_that(p.cargo_process("run").arg("--bin").arg("foo"),
                execs().with_status(0));
}

The problem appears to be that cargo should look for src/bin/main.rs as well as src/main.rs for defaults when named binaries are not found in src/bin/<name>.rs. This was introduced in e3edc06.

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