The old struct tail functions did not deal with `<T as Trait>::A` and `impl
Trait`, at least not explicitly. (We didn't notice this bug before because it
is only exposed when the tail (post deep normalization) is not `Sized`, so it
was a rare case to deal with.)
For post type-checking (i.e. during codegen), there is now
`struct_tail_erasing_lifetimes` and `struct_lockstep_tails_erasing_lifetimes`,
which each take an additional `ParamEnv` argument to drive normalization.
For pre type-checking cases where normalization is not needed, there is
`struct_tail_without_normalization`. (Currently, the only instance of this is
`Expectation::rvalue_hint`.)
All of these new entrypoints work by calling out to common helper routines.
The helpers are parameterized over a closure that handles the normalization.
Rollup of 5 pull requests
Successful merges:
- #61853 (Emit warning when trying to use PGO in conjunction with unwinding on …)
- #62278 (Add Iterator::partition_in_place() and is_partitioned())
- #62283 (Target::arch can take more than listed options)
- #62393 (Fix pretty-printing of `$crate` (take 4))
- #62474 (Prepare for LLVM 9 update)
Failed merges:
r? @ghost
Prepare for LLVM 9 update
Main changes:
* In preparation for opaque pointer types, the `byval` attribute now takes a type. As such, the argument type needs to be threaded through to the function/callsite attribute application logic.
* On ARM the `+fp-only-sp` and `+d16` features have become `-fp64` and `-d32`. I've switched the target definitions to use the new names, but also added bidirectional emulation so either can be used on any LLVM version for backwards compatibility.
* The datalayout can now specify function pointer alignment. In particular on ARM `Fi8` is specified, which means that function pointer alignment is independent of function alignment. I've added this to our datalayouts to match LLVM (which is something we check) and strip the fnptr alignment for older LLVM versions.
* The fmul/fadd reductions now always respect the accumulator (including for unordered reductions), so we should pass the identity instead of undef.
Open issues:
* https://reviews.llvm.org/D62106 causes linker errors with ld.bdf due to https://sourceware.org/bugzilla/show_bug.cgi?id=24784. To avoid this I've enabled `RelaxELFRelocations`, which results in a GOTPCRELX relocation for `__tls_get_addr` and avoids the issue. However, this is likely not acceptable because relax relocations are not supported by older linker versions. We may need an LLVM option to keep using PLT for `__tls_get_addr` despite `RtLibUseGOT`.
The corresponding llvm-project PR is https://github.com/rust-lang/llvm-project/pull/19.
r? @ghost
Target::arch can take more than listed options
A list of options in a comment like this is almost guaranteed to become out of date: right now it is missing "riscv32" and "riscv64" and perhaps other architectures as well.
Add Iterator::partition_in_place() and is_partitioned()
`partition_in_place()` swaps `&mut T` items in-place to satisfy the
predicate, so all `true` items precede all `false` items. This requires
a `DoubleEndedIterator` so we can search from front and back for items
that need swapping.
`is_partitioned()` checks whether the predicate is already satisfied.
Rollup of 9 pull requests
Successful merges:
- #62417 (Fix ICEs when `Self` is used in type aliases)
- #62450 (Raise the default recursion limit to 128)
- #62470 (Prevent shrinking of "crate select" element on Firefox)
- #62515 (cli: make help output for -l and -L consistent)
- #62520 (Regression test for issue 42574.)
- #62526 (normalize use of backticks in compiler messages for libsyntax/feature_gate.rs)
- #62527 (clarify that debug_assert does not completely omits the code)
- #62535 (ci: Configure $CI_JOB_NAME correctly)
- #62541 (Add spastorino for rustc-guide toolstate)
Failed merges:
r? @ghost
`partition_mut()` swaps `&mut T` items in-place to satisfy the
predicate, so all `true` items precede all `false` items. This requires
a `DoubleEndedIterator` so we can search from front and back for items
that need swapping.
`is_partitioned()` checks whether the predicate is already satisfied.
clarify that debug_assert does not completely omits the code
TIL that debug_assert is implemented using `if cfg!(debug_assertions)`
rather than `#[cfg(debug_assertions)]`. This means one can not use API
gated with `#[cfg(debug_assertions)]` in `debug_assert` family of
macros.
Regression test for issue 42574.
Cc #42574.
I'm not going to say this *closes* that issue yet, for two reasons:
1. I am still confused about some aspects of the behavior we are observing that bug
2. The "fix" to the diagnostic relies on full NLL (`#![feature(nll)]`); migration mode still has a subpar diagnostic.
Raise the default recursion limit to 128
The previous limit of 64 is being (just) barely hit by genuine code out there, which is causing issues like https://github.com/rust-lang/rust/issues/62059 to rear their end.
Ideally, we wouldn’t have such arbitrary limits at all, but while we do, it makes a lot of sense to just raise this limit whenever genuine use-cases end up hitting it.
r? @pnkfelix
Fixes https://github.com/rust-lang/rust/issues/62059
Fix ICEs when `Self` is used in type aliases
I think it is right just to disallow this at resolution stage rather than let typeck produce a cyclic error. This is in line with previous behaviour. There was probably no need at all for the change that introduced this bug in #57428, so I've simply reversed it.
Fixes#62263, #62364, #62305.
r? @eddyb
Normalize projections appearing in `impl Trait`
Fixes#60414
This does not try to do the same for `existential type`s (which have the same bug), since that always seems to lead to cycle errors.
Exit arm scopes
Due to a bug in the HIR CFG construction, borrows for arm scopes were incorrectly leaking into other arms.
This PR also includes some drive-by improvements to `-Zunpretty=hir,identified` that would have been helpful while investigating this.
Closes#62107
TIL that debug_assert is implemented using `if cfg!(debug_assertions)`
rather than `#[cfg(debug_assertions)]`. This means one can not use API
gated with `#[cfg(debug_assertions)]` in `debug_assert` family of
macros.