Description
These are all legal, and somewhat strange, since they're not really following the file-system analogy that modules are typically explained with. I expect this behaviour is just whatever happens to fall out of the current implementation strategy, so let's make a more explicit decision one way or another.
static X: u8 = { mod foo; 0 };
fn foo() {
mod foo;
}
fn main() {
mod foo;
}
As one might expect, each of these is a distinct instance of foo
(which can be verified by placing log_syntax(hello)
in foo.rs
: the compiler will greet you 3 times).
Noticed in https://users.rust-lang.org/t/are-module-declarations-allowed-inside-functions/3583 .