I do like this proposal, but I have three concerns:
a) this will make the layout for “simple” projects more complex. As an example, right now I have project with this layout:
src/
hydra.rs
nixpkgs.rs
package.rs
...
mod.rs
bin/
foo.rs
bar.rs
With this proposal, I’d have to change that to
src/
hydra/
mod.rs
nixpkgs/
mod.rs
package/
mod.rs
...
mod.rs # this is perhaps unnecessary
bin/
foo.rs
bar.rs
Perhaps there could be the convention that automatic merging is only done if a mod.rs (or another name) file is present, so you can still use simple files for simple modules? Of course, that introduces another special case which hurts learnability…
b) Is there a particular reason why this proposal only considers pub(crate) and pub modules, but not pricate ones?
c) I fear that learnability may not be solved by adding to the language. Adding makes the language more complex, it cannot really reduce complexity (just hide it, and this is always leaky) as can be seen with C++ for example.