Open
Description
Right now this is possible and compiles without warning:
Given a cargo crate with name "foo":
// src/lib.rs
// src/main.rs
mod lib;
fn main() {}
... even though we now have duplicated code in the library "foo" and the submodule "lib"
This can be confusing for a beginner because the code can still compile or just breaks "late" depending on what you do:
// src/lib.rs
pub struct Foo;
// src/main.rs
mod lib;
// either of those work (though not at the same time):
use foo::Foo;
use crate::lib::Foo;
fn main() {}
cargo or rustc should detect if we use lib.rs
as a submodule, and warn or error against it.
This issue assumes 2018 edition without uniform paths syntax.