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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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