resolve: Bind primitive types to items in libcore#32274
resolve: Bind primitive types to items in libcore#32274petrochenkov wants to merge 5 commits intorust-lang:masterfrom
Conversation
|
Why not |
|
Lang items have to be unique, no? |
I would still allow the impls to be in different crates (if I'm understanding this right) but move the types in |
|
The problem is not in impls, but in shadowing. |
|
@petrochenkov What's in |
Hm, only |
|
@petrochenkov Even if stabilized, couldn't move everything but |
|
|
|
@petrochenkov Why do all of these things depend on an unicode library that we don't want to have in |
src/librustc_resolve/lib.rs
Outdated
There was a problem hiding this comment.
I'd prefer to check for Def::Err explicitly instead of introducing the method opt_def_id.
There was a problem hiding this comment.
Def::Err and Def::SelfTy, but anyway, def kind doesn't matter here, only the presence of def_id.
|
Reviewed, looks good to me. |
|
(The failure caught by Travis happens only during docs generation for |
|
Could |
|
@drbo I believe the issue is that |
|
I know there are plans to make a snapshot in the near future, it would be ideal to land this PR before that snapshot. |
|
eh we're still in "make snapshots whenever" mode so it's not like we can't have one for another 6 months :) I went ahead and kicked one off as @eddyb requested it, but if this lands we can just make a new one. |
|
☔ The latest upstream changes (presumably #32302) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Rebased. |
|
☔ The latest upstream changes (presumably #32054) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Rebased. |
|
Closing as per #32131 (comment) |
This is a more radical alternative to #32131
A new attribute
#[primitive_type]is introduced. If path used in type position resolves to a#[primitive_type]item, the definition of a primitive type with the same name is used instead of this item.A path cannot resolve to a primitive type in any other way. Several different
#[primitive_type]items can be resolved to one primitive type.Most of primitive types are bound to modules (
core::u8,core::stretc.) for backward compatibility.All the primitive type items are added to the prelude.
Pros:
This makes primitive types appear to be less special and more similar to lang items - they are defined in
libcore(and alsolibcollections,librustc_unicodeandlibstd), shadowed by other items (including modules) and need to be imported before use (but prelude does it for you).Cons:
It doesn't makes name resolution simpler internally, primitive types are still a hardcoded limited set of
Def::PrimTys known to the compiler.It puts the burden of defining/importing primitive types on
#[no_core]and#[no_implicit_prelude]code. The alternative PR presents them as the second small prelude which is hardcoded and has lower priority, so the primitive types are always available.[breaking-change]
Needs crater before proceeding.
cc #32131 (comment)
cc @jseyfried
r? @eddyb