This may be primarily a terminology issue. The statement mod name;
is exactly equivalent to
mod name {
include!("name.rs");
}
(where name.rs
is the location found by the compiler's search).
Though the text of the text of the module body may be loaded from a different disk file, it's still a new module definition-- every one of these statements will create a new instance in the module tree and the compiler will treat each of them as if they're completely unrelated to each other.
You are correct that use
"just creates a shorter way to refer to a value in another module," but that's more commonly referred to as "importing a value from another namespace/module". You can't import something that hasn't been defined, so you can always trace a use
statements to some originating mod
statement. What you can't do is replace that use
with another copy of the mod
statement; that means something entirely different, and is almost never what you want.
Another way to think about it is this: Rust modules are static singleton objects, and exactly one is created for each mod
statement in the source code. The file-loading behavior of mod
statements is secondary to this, a programmer convenience that doesn't alter their basic operation.