We're in Spaaaaace @adotinthevoid @BoxyUwU
struct bar {}
fn bar() {}
const foo: usize = 1;
fn foo() {}
Solution
error[E0428]: the name `foo` is defined multiple times
--> examples/misc_8.rs:8:1
|
7 | const foo: usize = 1;
| --------------------- previous definition of the value `foo` here
8 | fn foo() {}
| ^^^^^^^^ `foo` redefined here
|
= note: `foo` must be defined only once in the value namespace of this module
For more information about this error, try `rustc --explain E0428`.
error: could not compile `code` (example "misc_8") due to 1 previous error
Types and values live in separate namespaces as it is usually possible to syntactically determine whether an identifier should be for a value or type.
This means that struct bar {} is part of the type namespace, whereas fn bar is part of the value namespace (as functions in Rust are first
class values).
This allows for both of these declarations to co-exist.
However, const foo and fn foo are both part of the value namespace, causing a compiler error.