Remove a gotcha from book/error-handling.md
The book's "Error handling with `Box<Error>`" section talks about `Box<Error>`. In the actual example `Box<Error + Send + Sync>` is used instead so that the corresponding From impls could be used to convert a plain string to an error type. Rust 1.7 added support for conversion from `&str`/`String` to
`Box<Error>`, so this gotcha and later references to it can now be removed.
r? @steveklabnik
Rewrote "How Safe and Unsafe Interact" Nomicon chapter.
The previous version of the chapter covered a lot of ground, but was a little meandering and hard to follow at times. This draft is intended to be clearer and more direct, while still providing the same information as the previous version.
r? @steveklabnik
Have included an example of a Cargo.toml file containing the libc dependency.
The file has been reformatted to use sections. The note on the default features warning is part of the _Using libc_ section but is in bold.
Minor changes to variable bindings chapter
* In "*... name as another binding, that's currently in scope, will ...*", *"
that's currently in scope"* is not a parenthetical element, and the commas
can be omitted.
* Other minor changes.
* In "... name as another binding, that's currently in scope, will ...", ",
that's currently in scope, " is not a parenthetical element, and the commas
can be omitted.
* Other minor changes.
The book's "Error handling with Box<Error>" section talks about Box<Error>.
In the actual example Box<Error + Send + Sync> is used instead so that the
corresponding From impls could be used to convert a plain string to an error
type. Rust 1.7 added support for conversion from &str/String to
Box<Error>, so this gotcha and later references to it can now be removed.
Rename main thread from "<main>" to "main".
Fix issue #33789
We may need to discuss whether this counts as a breaking change since code may check the main thread name against "\<main\>". Discussion is in #33789
Fix a few links in the book
Links to directories and direct links to doc.rust-lang.org don't work properly
when viewing the docs offline so fix them.
r? @steveklabnik
The previous version of the chapter covered a lot of ground, but was a little
meandering and hard to follow at times. This draft is intended to be clearer
and more direct, while still providing the same information as the previous
version.
Clarify the English translation of `?Sized`
* It wasn't clear whether `?Sized` meant "not `Sized`" or "`Sized` or not `Sized`". According to #rust IRC, it does indeed mean "`Sized` or not `Sized`".
* Use the same language as [Trait std::marker::Sized](https://doc.rust-lang.org/std/marker/trait.Sized.html) about how `Sized` is implicitly bound.
* Refer to the syntax as `?Sized`, since it's currently the only allowed trait that can follow `?`.
Book: small improvement to a table to make it clearer
This table is used as an example of four heap values where two of them got deallocated leaving a gap.
It also has stack variables.
Instead of four stack variables I propose three, that way there's no misleading connection between the number of stack variables and heap variables.
But more importantly: three of the four stack variables had the same name (**y**) which could be confusing to a beginner, I changed this as well.
* Use "special bound syntax" instead of "special syntax". `?Sized` is technically a "bound", but `?Sized` is specialized syntax that _only_ works with `Sized`, and no other Trait.
* Replace "constant size" with "sized".
* It wasn't clear whether `?Sized` meant "not `Sized`" or "`Sized` or not `Sized`". According to #rust IRC, it does indeed mean "`Sized` or not `Sized`".
* Use the same language as [Trait std::marker::Sized](https://doc.rust-lang.org/std/marker/trait.Sized.html) about how `Sized` is implicitly bound.
Rust syntax coloring for some ignore, should-panic and no-run snippets.
In the book, some code blocks were missing the `rust` specifier which is needed for them to highlight correctly.
Add a note about Higher-Ranked Trait Bounds in docs on Closures.
I hit a snag with lifetimes a few days ago and it wasn't until @birkenfeld pointed out Higher-Ranked Trait Bounds that I was able to solve the issue involving lifetimes on closure traits. This adds a small section in the book so that other users can find it.
r? @steveklabnik
When using closures that take references with explicit lifetimes sometimes
it's required to use where F: for<..> ... syntax to express the right
lifetimes. This adds a quick note to the docs so other users can discover
it as well.
trivial tweaks to documentation (book)
These are small things I found while reading through The Book. The `<hash>` and `panic!` lines are simply to improve readability, while I believe the proceeding/following distinction is a bug (but might be a English dialect distinction?).
I've read `rust/CONTRIBUTING`, i'm not sure if there is anything I need to do other than submit this PR.
r? @steveklabnik
rustdoc: remove artificial indentation of doctest code
The indentation makes the examples look nicer when printed (when is this done?), but breaks tests using multi-line string literals.
Fixes: #25944
book: fixup code in error handling tutorial
A few oversights happened while porting the example from docopt to getopts. I retraced all the steps, fixing code and description as necessary.
Fixes: #33422
Add armv7-linux-androideabi target
This PR adds `armv7-linux-androideabi` target that matches `armeabi-v7a` Android ABI, ~~downscales `arm-linux-androideabi` target to match `armeabi` Android ABI~~ (TBD later if needed).
This should allow us to get the best performance from every [Android ABI level](http://developer.android.com/ndk/guides/abis.html).
Currently existing target `arm-linux-androideabi` started gaining features out of the supported range of [android `armeabi`](http://developer.android.com/ndk/guides/abis.html). While android compiler does not use a different target for later supported `armv7` architecture, it has distinct ABI name `armeabi-v7a`. We decided to add rust target `armv7-linux-androideabi` to match it.
Note that `NEON`, `VFPv3-D32`, and `ThumbEE` instruction sets are not added, because not all android devices are guaranteed to support all or some of these, and [their availability should be checked at runtime](http://developer.android.com/ndk/guides/abis.html#v7a).
~~This reduces performance of existing `arm-linux-androideabi` and may make it _much_ slower (we are talking more than order of magnitude in some random ad-hoc fp benchmark that I did).~~
Part of #33278.
A few oversights happened while porting the example from docopt to
getopts. I retraced all the steps, fixing code and description as
necessary.
Fixes: #33422
The definition of this value recently changed slightly. It no
longer corresponds directly to the target triple.
Also shuffled things around to make the order of cfg descriptions more
logical and added text related them to the target triple.
cc #33403
Fix use of the `move` command in the Windows shell
`move` works both in `cmd` and in Powershell. `mv` works only in Powershell and the book says nothing about which shell is recommended so this could confuse beginners.
Closes#33219.
Tweaks to sections related to Ownership
Reading through these sections, I thought the intro text could be improved slightly. So
here is a PR that addresses what was bugging me about it. :-)
Main issue was the wording of the opening sentence ("guide" is not clearly defined and the
wording was a bit too terse in my opinion). I also took issue with the term "one of the most
unique". Uniqueness is a `bool`, not an `f64`. :-)
r? @steveklabnik
I made the "tuple structs are useless" editorializing a bit weaker and moved it to the end. Feel free to overrule me on that.
I also added an example of how to unpack a tuple struct with dot notation, because it came up on IRC.
`braced_empty_structs` is stable now, so I updated the example for unit-like structs to use that syntax. Should we show both ways?
cc @ubsan
r? @steveklabnik or @GuillameGomez
`move` work both in `cmd` and in Powershell. `mv` works only in Powershell and the book says nothing about which shell is recommended so this could confuse beginners.
Closes#33219.
rustbuild: Run all markdown documentation tests
This commit adds support to rustbuild to run all documentation tests, basically
running `rustdoc --test` over all our documentation.
doc: Update our tier support
This modifies our listing of tiered platforms a few ways:
* All lists are alphabetized based on target now
* Lots of targets are moved up to "Tier 2" as we're gating on all these builds
and official releases are provided (and installable via rustup).
* A few targets now list having a compiler + cargo now as well.
No more platforms have been moved up to Tier 1 at this time, however. The only
real candidate is ``x86_64-unknown-linux-musl`, but that's not *quite* to a tier
1 level of quality just yet so let's hold off for another release or so to iron
it out a bit.