-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
No way to reference primitives by absolute path #44865
Comments
Since the // in libcore or libstd:
#[allow(non_camel_case_types)]
pub mod primitives {
mod details {
pub type Bool = bool;
pub type Char = char;
// ...
}
pub type bool = details::Bool;
pub type char = details::Char;
// ...
} |
|
Related: #32131 The reason these primitives are not put into prelude was because
but I think this is no longer a problem? (cc @petrochenkov) |
Tagging this as a library issue. The solution (if it happens on our side) is to add a module In the meantime Diesel can privately define such a module itself and use it when unintended shadowing can happen. It doesn't make much sense to put primitive types into the std prelude because they are already in a prelude actually, it's just not the std prelude, but an additional language prelude one level below (as it was decided in #32131 and #32274). |
I agree that primitives should be exposed at some absolute path. |
@dtolnay I'd be happy to work on this. What's needed besides the implementation? I'm not entirely sure what a test for this should look like. Just a run-pass test that shadows |
I would start with a PR that has:
|
Sounds good. I'll try to get that PR done this week. |
Does this need a feature gate? |
Yes I believe so. |
Triage: not aware of anything happening here. |
…olnay Add primitive module to libcore This re-exports the primitive types from libcore at `core::primitive` to allow macro authors to have a reliable location to use them from. Fixes rust-lang#44865
I got a bug report on Diesel from someone who has a database column called
bool
. This lead to us attempting to generate the following code:which causes a type mismatch because their struct is shadowing the primitive. I'd like to change the generated code to be
const HAS_STATIC_QUERY_ID: ::std::bool
, which is the path that the rustdoc for libstd indicates it should be, but the type doesn't exist there, or anywhere else I can find. I would assume the same issue exists forstr
,char
, and all the numeric types.The text was updated successfully, but these errors were encountered: