Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upresolve: Bind primitive types to items in libcore #32274
Conversation
rust-highfive
assigned
eddyb
Mar 15, 2016
This comment has been minimized.
This comment has been minimized.
|
Why not |
eddyb
added
the
S-waiting-on-crater
label
Mar 15, 2016
This comment has been minimized.
This comment has been minimized.
|
Lang items have to be unique, no? |
This comment has been minimized.
This comment has been minimized.
I would still allow the impls to be in different crates (if I'm understanding this right) but move the types in |
This comment has been minimized.
This comment has been minimized.
|
The problem is not in impls, but in shadowing. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov What's in |
This comment has been minimized.
This comment has been minimized.
Hm, only |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Even if stabilized, couldn't move everything but |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Why do all of these things depend on an unicode library that we don't want to have in |
jseyfried
reviewed
Mar 16, 2016
| // Check if the resolution is a #[primitive_type] item in type namespace, | ||
| // replace that item with a primitive type with the same name. | ||
| if let Some(PathResolution{base_def, ..}) = resolution { | ||
| if let Some(def_id) = base_def.opt_def_id() { |
This comment has been minimized.
This comment has been minimized.
jseyfried
Mar 16, 2016
Contributor
I'd prefer to check for Def::Err explicitly instead of introducing the method opt_def_id.
This comment has been minimized.
This comment has been minimized.
petrochenkov
Mar 16, 2016
Author
Contributor
Def::Err and Def::SelfTy, but anyway, def kind doesn't matter here, only the presence of def_id.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Reviewed, looks good to me. |
This comment has been minimized.
This comment has been minimized.
|
(The failure caught by Travis happens only during docs generation for |
This comment has been minimized.
This comment has been minimized.
|
Could |
This comment has been minimized.
This comment has been minimized.
|
@drbo I believe the issue is that |
jseyfried
referenced this pull request
Mar 17, 2016
Merged
resolve: Minimize hacks in name resolution of primitive types #32131
This comment has been minimized.
This comment has been minimized.
|
I know there are plans to make a snapshot in the near future, it would be ideal to land this PR before that snapshot. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov
force-pushed the
petrochenkov:prim3
branch
from
25e5747
to
8b6af5f
Mar 21, 2016
This comment has been minimized.
This comment has been minimized.
|
Rebased. |
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov
added some commits
Mar 8, 2016
petrochenkov
force-pushed the
petrochenkov:prim3
branch
from
8b6af5f
to
fd4d564
Mar 21, 2016
This comment has been minimized.
This comment has been minimized.
|
Rebased. |
This comment has been minimized.
This comment has been minimized.
|
Closing as per #32131 (comment) |
petrochenkov commentedMar 15, 2016
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