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 upMake `str` a library type (and lang item) #19036
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Nominating. I think this is P-backcompat-libs, but not 1.0 (since we can live with the extension traits if we have to). |
aturon
added
A-libs
A-typesystem
I-nominated
labels
Nov 17, 2014
This comment has been minimized.
This comment has been minimized.
|
Interesting! I tried this once before, and found an ICE which has been already solved. I'll give it another try soon (only the library side, I don't know how to do the lang item part) |
This comment has been minimized.
This comment has been minimized.
|
@japaric Awesome! Let me know if I can do anything to help. |
This comment has been minimized.
This comment has been minimized.
|
When we discussed things at the work week where we planned out DST, we did intend for |
This comment has been minimized.
This comment has been minimized.
|
@aturon As a test I created the About the implementation process, I guess these are the steps to take?
I really hope that we would be able to split the work like that (although probably parts 2 and 3 will have to get done at the same time), otherwise it's going to be a big patch. Also, depending if we want to rename |
This comment has been minimized.
This comment has been minimized.
|
@japaric what do you mean by "adding a str lang item" as a step? that seems like it's... a line in a table, or perhaps you mean something more? |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis I meant modify the compiler to allow something like this: #[lang = "str"]
struct Str([u8]);
let foo: &'static Str = "Hello world!";Or can I simply do: // libcore/str.rs
struct str([u8]);
impl str { fn contains__(&self, needle: &str) -> bool { /* .. */ } }
// and this will just work?
let foo: &'static str = "Hello!";
assert!(foo.contains__("el")); |
This comment has been minimized.
This comment has been minimized.
|
@japaric no, we will definitely need a lang item, but it seems like at least some of the steps you listed must be done atomically (adding the lang item; changing the type of literals to use this lang item). We could (and should) move the extension traits over separately, once that transition is done. Is this the staging you had in mind? |
This comment has been minimized.
This comment has been minimized.
|
(If nothing else, we probably want to do a snapshot before changing the extension traits) |
This comment has been minimized.
This comment has been minimized.
|
Oh, and: I think that we should not change the name of |
This comment has been minimized.
This comment has been minimized.
Yes, something like that. I can help with the second part (extension trait removal). (I'd help with the first part (lang item + literals) but I'm not familiar with the compiler internals, it'll be faster if someone who is familiar with that part works on it). |
This comment has been minimized.
This comment has been minimized.
|
If we get to this before 1.0, then we'll remove the extension traits. If we don't, then we'll just have to keep the extension traits around. But that's something we can live with. So, P-high, not 1.0. |
pnkfelix
added
P-medium
and removed
I-nominated
labels
Nov 20, 2014
kmcallister
added
the
A-collections
label
Jan 16, 2015
This comment has been minimized.
This comment has been minimized.
|
This is still wanted? It seemed like #19612 it was stated that the core team has changed its mind... |
This comment has been minimized.
This comment has been minimized.
|
@seanmonstar Thanks for the ping. I'm going to close this issue, since it was determined that this change had more downsides than benefits. |
aturon
closed this
Feb 6, 2015
This comment has been minimized.
This comment has been minimized.
|
Was mostly curious since @brson just linked it on the discuss thread about nice-to-haves for 1.0. |
aturon commentedNov 17, 2014
With DST, there is no longer any reason that
strneeds to be a primitive type; it can instead be defined in the library as a newtype wrapper around[u8]. (It will, of course, still need to be a lang item for string literals to work).The main visible consequence of this change would be the removal of several prelude traits in favor of inherent methods -- so it has some impact on library stabilization.
It may also be that the name could/should be revisited if it is no longer primitive.