The enums chapter at the moment is ... weird. The examples aren't about enums, they're about structs, and most of the chapter talks about how enums don't support comparison operators by default (which is also true of other compound data types.) I think there was a story here once, but some coherency got lost in refactoring.
There are two preliminary patches here, one to combine the struct and tuple-struct chapters, and one to document unit-like structs, because enum syntax is easier to explain once you have those three. The final patch moves the enum chapter after the struct chapter, and rewrites most of it to talk about enums usefully (including covering matches on enums).
r? @steveklabnik
This makes the compatibility matrix render a little nicer on github, and also removes a note about windows support from 0.12 (Which is immaterial now that we're approaching 1.0)
Attempted to organize them in a way more relevant to what newbies
would be interested in hearing.
I am not satisfied by this at all, but by virtue of deleting old links alone I think it is an improvement.
r? @steveklabnik
I did a read through of the manual. This commit corrects various small points and expands some sections, while avoiding too much detail.
r? @steveklabnik
At the moment, http://doc.rust-lang.org/error-index.html isn't linked to from anywhere (except Reddit). This should allow search engines to find error codes!
I also capitalised "The Standard Library" and neatened a few bits of grammar.
Also fixed: `#[main]` inside one of the error descriptions.
Add diagnostic message for E0317, E0154, E0259 and E0260; part of #24407.
About E0317, I was unsure if I should add an example of what could be wrong, such as `struct i64`, `enum char { A, B }` or `type isize = i64`. I decided against it, since the diagnostic message looks clear enough to me.
What do you think?
I corrected some pretty obvious textual mistakes. One thing requires more attention - the paragraph at line 133 in Ownership. It was confusing, so I changed it, but I am no sure if this is what the author had in mind.
core::slice was originally written to tolerate overflow (notably, with
slices of zero-sized elements), but it was never updated to use wrapping
arithmetic when overflow traps were added.
Also correctly handle the case of calling .nth() on an Iter with a
zero-sized element type. The iterator was assuming that the pointer
value of the returned reference was meaningful, but that's not true for
zero-sized elements.
Fixes#25016.
It is currently broken to use syntax such as `<T as Foo>::U::static_method()` where `<T as Foo>::U` is an associated type. I was able to fix this and simplify the parser a bit at the same time.
This also fixes the corresponding issue with associated types (#22139), but that's somewhat irrelevant because #22519 is still open, so this syntax still causes an error in type checking.
Similarly, although this fix applies to associated consts, #25046 forbids associated constants from using type parameters or `Self`, while #19559 means that associated types have to always have one of those two. Therefore, I think that you can't use an associated const from an associated type anyway.
The loop to load all the known impls from external crates seems to have been used because `ty::populate_implementations_for_trait_if_necessary` wasn't doing its job, and solely relying on it resulted in loading only impls in the same crate as the trait.
Coherence for `librustc` was reduced from 18.310s to 0.610s, from stage1 to stage2.
Interestingly, type checking also went from 46.232s to 42.003s, though that could be noise or unrelated improvements.
On a smaller scale, `fn main() {}` now spends 0.003s in coherence instead of 0.368s, which fixes#22068.
It also peaks at only 1.2MB, instead of 16MB of heap usage.
A few errors slipped through my filter. Markdown formatting is especially important now that http://doc.rust-lang.org/error-index.html is live!
Speaking of, the error index should probably be linked to from somewhere. It doesn't quite fit under any of the sections in the index, but I could create a new one for it? Or add it under "tools" despite it not exactly being an executable tool.