gccrs
gccrs copied to clipboard
private constants should not be accessed from outer namespace
It is also true for static items?
I tried this code:
pub mod module_a {
const CONST_I32: i32 = 0;
}
fn main() {
let _ = module_a::CONST_I32;
}
I expected to see this happen:
error[E0603]: constant `CONST_I32` is private
--> <source>:6:23
|
6 | let _ = module_a::CONST_I32;
| ^^^^^^^^^ private constant
|
note: the constant `CONST_I32` is defined here
--> <source>:2:5
|
2 | const CONST_I32: i32 = 0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
Instead, this happened: compiled.
Meta
- What version of Rust GCC were you using, git sha if possible.
Yeah, this is also true for static items: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=127506396739337c8e60b56c91427c69
Thanks for the report!