Rollup of 14 pull requests
Successful merges:
- #55767 (Disable some pretty-printers when gdb is rust-enabled)
- #55838 (Fix #[cfg] for step impl on ranges)
- #55869 (Add std::iter::unfold)
- #55945 (Ensure that the argument to `static_assert` is a `bool`)
- #56022 (When popping in CTFE, perform validation before jumping to next statement to have a better span for the error)
- #56048 (Add rustc_codegen_ssa to sysroot)
- #56091 (Fix json output in the self-profiler)
- #56097 (Fix invalid bitcast taking bool out of a union represented as a scalar)
- #56116 (ci: Download clang/lldb from tarballs)
- #56120 (Add unstable Literal::subspan().)
- #56154 (Pass additional linker flags when targeting Fuchsia)
- #56162 (std::str Adapt documentation to reality)
- #56163 ([master] Backport 1.30.1 release notes)
- #56168 (Fix the tracking issue for hash_raw_entry)
Failed merges:
r? @ghost
Pass additional linker flags when targeting Fuchsia
This is a follow up to 8aa9267 which changed the driver to use lld
directly rather than invoking it through Clang. This change ensures
we pass all the necessary flags to lld.
When popping in CTFE, perform validation before jumping to next statement to have a better span for the error
Currently, when validating the return value fails, the span points at the next statement after the call. That does not make much sense.
r? @oli-obk
Add std::iter::unfold
This adds an **unstable** ~`std::iter::iterate`~ `std::iter::unfold` function and ~`std::iter::Iterate`~ `std::iter::Unfold` type that trivially wrap a ~`FnMut() -> Option<T>`~ `FnMut(&mut State) -> Option<T>` closure to create an iterator. ~Iterator state can be kept in the closure’s environment or captures.~
This is intended to help reduce amount of boilerplate needed when defining an iterator that is only created in one place. Compare the existing example of the `std::iter` module: (explanatory comments elided)
```rust
struct Counter {
count: usize,
}
impl Counter {
fn new() -> Counter {
Counter { count: 0 }
}
}
impl Iterator for Counter {
type Item = usize;
fn next(&mut self) -> Option<usize> {
self.count += 1;
if self.count < 6 {
Some(self.count)
} else {
None
}
}
}
```
… with the same algorithm rewritten to use this new API:
```rust
fn counter() -> impl Iterator<Item=usize> {
std::iter::unfold(0, |count| {
*count += 1;
if *count < 6 {
Some(*count)
} else {
None
}
})
}
```
-----
This also add unstable `std::iter::successors` which takes an (optional) initial item and a closure that takes an item and computes the next one (its successor).
```rust
let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
```
Disable some pretty-printers when gdb is rust-enabled
A rust-enabled gdb already knows how to display string slices,
structs, tuples, and enums (and after #54004, the pretty-printers
can't handle enums at all). This patch disables these pretty-printers
when gdb is rust-enabled.
The "gdb-pretty-struct-and-enums-pre-gdb-7-7.rs" test is renamed,
because it does not seem to depend on any behavior of that version of
gdb, and because gdb 7.7 is 4 years old now.
Suggest correct syntax when writing type arg instead of assoc type
- When confusing an associated type with a type argument, suggest the appropriate syntax. Given `Iterator<isize>`, suggest `Iterator<Item = isize>`.
- When encountering multiple missing associated types, emit only one diagnostic.
- Point at associated type def span for context.
- Point at each extra type argument.
Follow up to #48288, fix#20977.
rustc_target: separate out an individual alignment quantity type from Align.
Before this PR, `rustc_target::abi::Align` combined "power-of-two alignment quantity" semantics, with a distinction between ABI (required) and preferred alignment (by having two quantities).
After this PR, `Align` is only *one* such quantity, and a new `AbiAndPrefAlign` type is introduced to hold the pair of ABI and preferred `Align` quantities.
`Align` is used everywhere one quantity is necessary/sufficient, simplifying some of the code in codegen/miri, while `AbiAndPrefAlign` only in layout computation (to propagate preferred alignment).
r? @oli-obk cc @nagisa @RalfJung @nikomatsakis