Update books
## nomicon
1 commits in bbf06ad39d1f45654047e9596b750cc6e6d1b693..adca786547d08fe676b2fc7a6f08c2ed5280ca38
2021-01-22 07:07:31 -0800 to 2021-02-16 16:34:20 +0900
- Merge pull request rust-lang-nursery/nomicon#254 from mdaverde/ml/adds-compiler-err-lifetimes
## reference
9 commits in f02b09eb6e8af340ad1256a54adb7aae2ff3163e..361367c126290ac17cb4089f8d38fd8b2ac43f98
2021-01-22 01:53:02 -0800 to 2021-02-15 09:58:13 -0800
- Define turbofish in the glossary (rust-lang-nursery/reference#964)
- Remove enum variant expr (rust-lang-nursery/reference#963)
- One sentence is one line src/expressions/* (rust-lang-nursery/reference#962)
- Referencify bool type (rust-lang-nursery/reference#940)
- Fix typo in type cast expression table (rust-lang-nursery/reference#959)
- Define rust (rust-lang-nursery/reference#953)
- Remove "Memory Ownership" chapter (rust-lang-nursery/reference#952)
- Added setting nightly as a requirement for running tests (rust-lang-nursery/reference#955)
- Refactored build steps for better readability (rust-lang-nursery/reference#936)
## book
13 commits in e724bd826580ff95df48a8533af7dec1080693d4..db5e8a5105aa22979490dce30e33b68d8645761d
2021-01-20 08:19:49 -0600 to 2021-02-12 16:58:20 -0500
- Update to Rust 1.50
- Fix issue rust-lang/book#2574 - Improve the explanation about the behaviour of `read_line`. (rust-lang/book#2575)
- closures: replace "is called" with "is defined" (rust-lang/book#2556)
- Minor clarification: types -> values in ch16-04 (rust-lang/book#2587)
- fixed hidden code listing (rust-lang/book#2610)
- Merge remote-tracking branch 'origin/pr/2604'
- (rust-lang/book#2601)
- Merge remote-tracking branch 'origin/pr/2589'
- Fix text wrapping
- Some small rewordings I noticed while rereading just now
- (rust-lang/book#2592)
- Removed 'of' between type alias in Ch 19-04. (rust-lang/book#2581)
- Merge remote-tracking branch 'origin/pr/2554'
## rust-by-example
2 commits in f633769acef68574427a6fae6c06f13bc2199573..551cc4bc8394feccea6acd21f86d9a4e1d2271a0
2021-01-13 20:58:25 -0300 to 2021-02-03 17:12:37 -0300
- remove // (rust-lang/rust-by-example#1409)
- Update arc.md (rust-lang/rust-by-example#1406)
## edition-guide
3 commits in b91a9a881ee007c12e74e844460ec407cf07a50f..1da3c411f17adb1ba5de1683bb6acee83362b54a
2020-11-02 11:02:03 -0600 to 2021-02-16 16:46:40 -0800
- Update link for no_std. (rust-lang-nursery/edition-guide#231)
- Add git link to the source. (rust-lang-nursery/edition-guide#228)
- Update musl libc link (rust-lang-nursery/edition-guide#230)
## embedded-book
1 commits in ceec19e873be87c6ee5666b030c6bb612f889a96..4cf7981696a85c3e633076c6401611bd3f6346c4
2021-01-03 13:13:10 +0000 to 2021-02-11 10:55:22 +0000
- Fix installing dateutil since it is now a dependency of the GHP import script (rust-embedded/book#282)
Document that `assert!` format arguments are evaluated lazily
It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:
```rust
assert!(
some_condition,
"The state is invalid. Details: {}",
expensive_call_to_get_debugging_info(),
);
```
It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
Don't fail to remove files if they are missing
In the backend we may want to remove certain temporary files, but in
certain other situations these files might not be produced in the first
place. We don't exactly care about that, and the intent is really that
these files are gone after a certain point in the backend.
Here we unify the backend file removing calls to use `ensure_removed`
which will attempt to delete a file, but will not fail if it does not
exist (anymore).
The tradeoff to this approach is, of course, that we may miss instances
were we are attempting to remove files at wrong paths due to some bug –
compilation would silently succeed but the temporary files would remain
there somewhere.
To digit simplification
I found out the other day that all the ascii digits have the first four bits as one would hope them to. (Eg. char `2` ends `0b0010`). There are two bits to indicate it's in the digit range ( `0b0011_0000`). If it is a true digit then all the higher bits aside from these two will be 0 (as ascii is the lowest part of the unicode u32 spectrum). So XORing with `0b11_0000` should mean we either get the number 0-9 or alternativly we get a larger number in the u32 space. If we get something that's not 0-9 then it will be discarded as it will be greater than the radix.
The code seems so fast though that there's quite a lot of noise in the benchmarks so it's not that easy to prove conclusively that it's faster as well as less instructions.
The non-fast path I was toying with as well wondering if we could do this as then we'd only have one return and less instructions still:
```
match self {
'a'..='z' => self as u32 - 'a' as u32 + 10,
'A'..='Z' => self as u32 - 'A' as u32 + 10,
_ => { radix = 10; self as u32 ^ ASCII_DIGIT_MASK},
}
```
Here's the [godbolt](https://godbolt.org/z/883c9n).
( H/T to ``@byteshadow`` for pointing out xor was what I needed)
Add 'consider using' message to overflowing_literals
Fixes#79744.
Ironically, the `overflowing_literals` handler for binary or hex already
had this message! You would think it would be the other way around :)
cc ```@scottmcm```
Only store a LocalDefId in some HIR nodes
Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef.
As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`.
This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
validation: fix invalid-fn-ptr error message
https://github.com/rust-lang/rust/pull/82061 changed the code here to print an `ImmTy` instead of a `ScalarMaybeUninit`; that was an accident. So go back to printing a `ScalarMaybeUninit`.
r? ```@oli-obk```
avoid full-slicing slices
If we already have a slice, there is no need to get another full-range slice from that, just use the original.
clippy::redundant_slicing
Fix ES5 errors (IE11)
rustdoc is supposed to run on IE11 but someone reported me that it wasn't. I just confirmed it by using `es-check` with the `es5` option like this:
```
$ es-check es5 src/librustdoc/html/static/*.js
```
The PR fixes those issues and add CI checks to prevent regressions.
`@Mark-Simulacrum:` I added checks in the CI, but not sure if it's the correct way to do it. Any help on that side would be very appreciated!
r? `@Nemo157`
It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:
```rust
assert!(
some_condition,
"The state is invalid. Details: {}",
expensive_call_to_get_debugging_info(),
);
```
It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
Ensures `make` tests run under /bin/dash (if available), like CI, and fixes a Makefile
Note: This cherrypicks #81688 (`@pnkfelix)`
Updates `tools.mk` to explicitly require `SHELL := /bin/dash`, since CI uses `dash` but other environments (including developer local machines) may default to `bash`.
Replaces bash-specific shell command in one Makefile with a dash-compatible alternative, and re-enables the affected Makefile test.
Removes apparently redundant definition of `UNAME`.
Also see: [zulip discussion thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/how.20to.20run.2Fbless.20src.2Ftest.2Frun-make-fulldeps.2Fcoverage.20.3F)
r? `@pnkfelix`
FYI: `@wesleywiser` `@tmandry`