Skip to content

src/main.rs is always built if it exists #22283

Description

@bfops

Create three files:

Cargo.toml:

[package]

name = "test"
version = "0.0.0"

[lib]

name = "lib"
path = "src/lib.rs"

src/lib.rs can be empty

src/main.rs:

arglebargle

Compiling the project gives:

[ben@windoze8isbest8 testbed]$ cargo build
   Compiling test v0.0.0 (file:///home/ben/testbed)
src/main.rs:1:1: 1:12 error: expected item, found `arglebargle`
src/main.rs:1 arglebargle
              ^~~~~~~~~~~
Could not compile `test`.

Removing main.rs or moving the files out of the src directory causes it to build fine.

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