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 upRedefining built-in types does not work #20427
Comments
This comment has been minimized.
This comment has been minimized.
|
Nominating. Seems like this should be well-defined, though this behavior may be so useless there's no backwards compat risk. |
brson
added
the
I-nominated
label
Jan 7, 2015
brson
added this to the 1.0 milestone
Jan 15, 2015
brson
added
P-backcompat-lang
and removed
I-nominated
labels
Jan 15, 2015
This comment has been minimized.
This comment has been minimized.
|
Could possibly do post-1.0 bugfix. |
brson
added
the
E-easy
label
Jan 15, 2015
This comment has been minimized.
This comment has been minimized.
|
@brson
the name lookup rightfully resolves |
This comment has been minimized.
This comment has been minimized.
|
So, the current algorithm is:
Modules, unlike most of other items, are not exposed to the discussed problem just because they are never full paths. It is possible to prohibit the built-in names only for items that can be used as full paths and are searched in type namespace, but IMO the most drastic solution would be the most appropriate here - prohibit built-in names for everything except for modules. Reusing the names of built-in types is never a good idea and modules are just an unfortunate exception. |
This comment has been minimized.
This comment has been minimized.
|
/cc @aturon |
This comment has been minimized.
This comment has been minimized.
To be clear: you're saying that you would not be able to define types (or values?) with names matching any primitive type? But modules are OK? That sounds potentially fine to me (and can always be relaxed later). |
This comment has been minimized.
This comment has been minimized.
Yes, only module items will be able to have names matching built-in types. |
petrochenkov
added a commit
to petrochenkov/rust
that referenced
this issue
Feb 8, 2015
This comment has been minimized.
This comment has been minimized.
|
A more fine-grained prohibition turned out to be easier to implement. |
bors
added a commit
that referenced
this issue
Feb 12, 2015
bors
added a commit
that referenced
this issue
Feb 12, 2015
bors
added a commit
that referenced
this issue
Feb 12, 2015
bors
added a commit
that referenced
this issue
Feb 13, 2015
mdinger
added a commit
to mdinger/rust
that referenced
this issue
Feb 14, 2015
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Has this been resolved? |
This comment has been minimized.
This comment has been minimized.
|
@aturon |
This comment has been minimized.
This comment has been minimized.
|
Thanks @petrochenkov! |
aturon
closed this
Feb 16, 2015
This comment has been minimized.
This comment has been minimized.
|
The implemented solution is only a band-aid and doesn't play well with post-UFCS rules and needs. |
eddyb
reopened this
Feb 16, 2015
eddyb
removed
the
E-easy
label
Feb 16, 2015
This comment has been minimized.
This comment has been minimized.
|
@eddyb |
This comment has been minimized.
This comment has been minimized.
|
I've tried to summarize some implications of UFCS, including this one, in a comment on the UFCS issue. |
pnkfelix
assigned
nrc
Apr 2, 2015
This comment has been minimized.
This comment has been minimized.
|
Note to self: what is the status now? |
This comment has been minimized.
This comment has been minimized.
|
assigning to @nrc to understand better what work remains here and how this should be proritized. |
This comment has been minimized.
This comment has been minimized.
|
To summarise the status: there is a fix (the issue was fixed not by allowing redefinition but preventing using the names of primitive types as the name of anything user-defined except for modules), however, there were then doubts that this fix may not play well with some of the consequences of UFCS, specifically how primitive types can be used as modules. There does now seem to be consensus that primitive types and their impls and modules are fixed by #23104 and so I don't believe there is anything else to do here. |
nrc
closed this
Apr 8, 2015
This comment has been minimized.
This comment has been minimized.
|
How so? #23104 does not make use of associated constants (#23606 is still not merged yet) so there is a chance things like The names of primitives cannot be considered a fixed set, so I still prefer a solution that explicitly puts them in the prelude - maybe the fix should be modified so it behaves like the primitives are always imported where the prelude would be, even if primitives aren't being rooted in libcore? |
This comment has been minimized.
This comment has been minimized.
|
@eddyb How do you think, would it make sense to migrate only part of primitive types to the new name lookup rules and keep the old rules for cc #8995 |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Sadly, it's backwards incompatible to change modules with the same name as types to anything else. |
This comment has been minimized.
This comment has been minimized.
|
Ah, right, |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov You can move all the named built-in types to the prelude while keeping the existing modules. It's not pretty, but it should work. |
This comment has been minimized.
This comment has been minimized.
Similar example with existing prelude type: |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov What if |
Marckvdv commentedJan 2, 2015
The following code does not do what I expect it to do: