-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modules with same names as built in types causes ICE #3315
Comments
From reading here: https://doc.rust-lang.org/reference/names/namespaces.html builtins and modules both belong in the Types namespace, however, that can't really be correct, since |
Also, look at this error: liam@newgame ~/projects/gccrs/gccrs-build $ rustc main.rs
...
error[E0605]: non-primitive cast: `i32` as `i32`
--> main.rs:4:18
|
4 | let a: i32 = 0 as i32;
| ^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0605`.
liam@newgame ~/projects/gccrs/gccrs-build $ cat main.rs
struct i32 {}
fn main() {
let a: i32 = 0 as i32;
}
liam@newgame ~/projects/gccrs/gccrs-build $ What happens here is that |
I guess what we are expected to do is remove builtin types from the resolution context when another EDIT: I tried this, but then mod i32 {}
fn main() {
let a: i32 = 0 as i32;
} |
Modules are clearly handled separately from other types like structs. I think modules are somehow part of their own namespace? EDIT: I checked rustc, structs, builtins, modules, etc are all in the Types namespace, at least at rustc's HIR level. They end up going into different RIB's though. I'm not really sure how you'd make this work yet though |
It looks like builtins are really supposed to go in a language prelude. That way, module definitions can shadow builtin definitions by virtue of being in a different scope. |
Would this be part of a distinct RIB? |
Yep. Fixing this would probably entail some adjustments to the |
Code
Meta
Version: gccrs (Compiler-Explorer-Build-gcc-b5c354d038f800695a8d730c56c4a4f744134adb-binutils-2.42) 14.0.1 20240309 (experimental)
Error output
The text was updated successfully, but these errors were encountered: