Remove `tokenstream::Delimited`.
Because it's an extra type layer that doesn't really help; in a couple
of places it actively gets in the way, and overall removing it makes the
code nicer. It does, however, move `tokenstream::TokenTree` further away
from the `TokenTree` in `quote.rs`.
More importantly, this change reduces the size of `TokenStream` from 48
bytes to 40 bytes on x86-64, which is enough to slightly reduce
instruction counts on numerous benchmarks, the best by 1.5%.
Note that `open_tt` and `close_tt` have gone from being methods on
`Delimited` to associated methods of `TokenTree`.
Because it's an extra type layer that doesn't really help; in a couple
of places it actively gets in the way, and overall removing it makes the
code nicer. It does, however, move `tokenstream::TokenTree` further away
from the `TokenTree` in `quote.rs`.
More importantly, this change reduces the size of `TokenStream` from 48
bytes to 40 bytes on x86-64, which is enough to slightly reduce
instruction counts on numerous benchmarks, the best by 1.5%.
Note that `open_tt` and `close_tt` have gone from being methods on
`Delimited` to associated methods of `TokenTree`.
This commit also fixes up lifetimes a bit:
- Renames `'a` as `'p` when used with `Matrix` and `Pattern`, for
consistency.
- Removes some unnecessary `'p` lifetimes on some function arguments.
- Adds some missing lifetime parameters.
slice: tweak concat & join
- use `sum` instead of `fold` (readability)
- adjust the capacity for `join` - the number of separators is `n - 1`, not `n`; proof:
```
fn main() {
let a = [[1, 2], [4, 5]];
let v = a.join(&3);
assert_ne!(v.len(), v.capacity()); // len is 5, capacity is 6
}
```
Update the book to fix some edition-related bugs
I'd love to have this included in a point release if one happens, but the changes aren't worth doing a point release on their own IMO. I'd definitely like to see this backported to beta.
The most urgent changes included here are:
- Chapter 19.6, on macros (including the macro changes that just stabilized), [is cut off](https://github.com/rust-lang/book/issues/1668) because of an ill-placed newline in a comment that [pulldown-cmark interprets incorrectly](https://github.com/raphlinus/pulldown-cmark/issues/124).
- [The `Cargo.toml` shown in the Guessing Game example in Chapter 2 (and one in Chapter 14) doesn't have `edition="2018"`](https://github.com/rust-lang/book/pull/1671), which can be confusing depending on whether the readers have it in theirs or not, think they should remove it if they have it, and the rest of the chapter assumes it's there and the code doesn't compile if you don't have it.
- The redirects implemented as part of only shipping the 2018 edition of the book sometimes lead to [having to click through 2 redirect pages](https://github.com/rust-lang/book/pull/1667) when it could be just one.
There are other small corrections included that were made since the last time the book was updated, but those aren't urgent.
cc @steveklabnik
name old ns/iter new ns/iter diff ns/iter diff % speedup
iter::bench_cycle_take_ref_sum 927,152 927,194 42 0.00% x 1.00
iter::bench_cycle_take_sum 938,129 603,492 -334,637 -35.67% x 1.55
resolve: Reduce some clutter in import ambiguity errors
Noticed in https://www.reddit.com/r/rust/comments/a3pyrw/announcing_rust_131_and_rust_2018/eb8alhi/.
The first error is distracting, but unnecessary, it's a *consequence* of the ambiguity error and appears because one of the ambiguous `actix` modules (unsurprisingly) doesn't have the expected name in it.
codegen: Fix va_list - aarch64 iOS/Windows
## Summary
Fix code generated for `VaList` on Aarch64 iOS/Windows.
## Details
According to the [Apple - ARM64 Function Calling Conventions]:
> ... the type va_list is an alias for char * rather than for the struct
> type specified in the generic PCS.
The current implementation uses the generic Aarch64 structure for `VaList`
for Aarch64 iOS. Switch to using the `char *` variant of the `VaList`
and use the corresponding `emit_ptr_va_arg` for the `va_arg` intrinsic.
Windows always uses the `char *` variant of the `VaList`. Update the `va_arg`
intrinsic to use `emit_ptr_va_arg`.
[Apple - ARM64 Function Calling Conventions]: https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html
Improve the usage message for `-Z dump-mir`.
Ouput now looks like this:
```
$ rustc -Z help
...
-Z arg-align-attributes -- emit align metadata for reference arguments
-Z dump-mir=val -- dump MIR state to file.
`val` is used to select which passes and functions to dump. For example:
`all` matches all passes and functions,
`foo` matches all passes for functions whose name contains 'foo',
`foo & ConstProp` only the 'ConstProp' pass for function names containing 'foo',
`foo | bar` all passes for function names containing 'foo' or 'bar'.
-Z dump-mir-dir=val -- the directory the MIR is dumped into
...
```
Fixes#56558