Harden the pre-tyctxt query system against accidental recomputation
While the current compiler has no issues where we `take` and then compute the query again, in https://github.com/rust-lang/rust/pull/105462 I accidentally introduced such a case.
I also took the opportunity to remove `peek_mut`, which is only ever used for `global_tcx` to then invoke `enter`. I added an `enter` method directly on the query.
Rollup of 10 pull requests
Successful merges:
- #106167 (Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311)
- #106309 (Prefer non-`[type error]` candidates during selection)
- #106532 (Allow codegen to unsize `dyn*` to `dyn`)
- #106596 (Hide more of long types in E0271)
- #106638 (std tests: use __OsLocalKeyInner from realstd)
- #106676 (Test that we cannot use trait impl methods arguments as defining uses)
- #106702 (Conserve cause of `ImplDerivedObligation` in E0599)
- #106732 (rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.)
- #106733 (Revert "warn newer available version of the x tool")
- #106748 (Clean up `OnUnimplementedFormatString::verify`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Remove `<dyn AstConv<'tcx>>::fun(c, ...)` calls in favour of `c.astconv().fun(...)`
This removes the need for <>><><><<>> dances and makes the code a bit nicer.
Not sure if `astconv` is the best name though, maybe someone has a better idea?
Move autoderef to `rustc_hir_analysis`
Not sure if this is a change we actually want, but autoderef really is only (functionally) used by `rustc_hir_analysis` and `rustc_hir_typeck`, so it probably should live there.
Instead, implement a separate autoderef helper in `TypeErrCtxt` for the one use-case that goes against the ordering of the crate graph..
Migrate mir_build diagnostics 2 of 3
The first three commits are fairly boring, however I've made some changes to the output of the match checking diagnostics.
Stabilize `::{core,std}::pin::pin!`
As discussed [over here](https://github.com/rust-lang/rust/issues/93178#issuecomment-1295843548), it looks like a decent time to stabilize the `pin!` macro.
### Public API
```rust
// in module `core::pin`
/// API: `fn pin<T>($value: T) -> Pin<&'local mut T>`
pub macro pin($value:expr $(,)?) {
…
}
```
- Tracking issue: #93178
(now all this needs is an FCP by the proper team?)
doc: rewrite doc for signed int::{carrying_add,borrowing_sub}
Reword the documentation for bigint helper methods, signed `int::{carrying_add,borrowing_sub}` (#85532).
This change is a follow-up to #101889, which was for the unsigned methods.
Clean up `OnUnimplementedFormatString::verify`
Lift the always-allowed symbols to a static array and replace a `match iter().find(...)` with `iter().any(...)`
Revert "warn newer available version of the x tool"
Reverts rust-lang/rust#104552
Running the x executable directly created an [issue](https://github.com/rust-lang/rust/issues/106469) here. There are other options for warning a user that a newer version of x exists in the issue's discussion as well.
r? `@jyn514`
std tests: use __OsLocalKeyInner from realstd
This is basically the same as https://github.com/rust-lang/rust/pull/100201, but for __OsLocalKeyInner:
Some std tests are failing in Miri on Windows because [this static](a377893da2/library/std/src/sys/windows/thread_local_key.rs (L234-L239)) is getting duplicated, and Miri does not handle that properly -- Miri does not support this magic `.CRT$XLB` linker section, but instead just looks up this particular hard-coded static in the standard library. This PR lets the test suite use the std static instead of having its own copy.
Fixes https://github.com/rust-lang/miri/issues/2754
r? `@thomcc`
Allow codegen to unsize `dyn*` to `dyn`
`dyn* Trait` is just another type that implements `Trait`, so we should be able to unsize `&dyn* Trait` into `&dyn Trait` perfectly fine, same for `Box` and other unsizeable types.
Fixes#106488
Prefer non-`[type error]` candidates during selection
Fixes#102130Fixes#106351
r? types
note: Alternatively we could filter out error where-clauses during param-env construction? But we still need to filter out impls with errors during `match_impl`, I think.
Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311
Fixes#105544
The problems: The suggestion given for E0311 has invalid syntax when the synthetic type parameter is used for Trait type in function declaration:
```rust
fn foo(d: impl Sized) -> impl Sized
```
instead of explicitly specified like the following:
```rust
fn foo<T: Sized>(d: T) -> impl Sized
```
In addition to the syntax error, the suggestions given for E0311 are not complete when multiple elided lifetimes are involved in lifetime bounds, not all involved parameters are given the named lifetime in the suggestions. For the following test case:
```
fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ {
(d, p)
}
```
a good suggestion should add the lifetime 'a to both d and p, instead of d only:
```
fn foo<'a>(d: impl Sized + 'a, p: &'a mut ()) -> impl Sized + '_ {
(d, p)
}
```
The Solution: Fix the syntax problem in the suggestions when synthetic type parameter is used, and also add lifetimes for all involved parameters.
Use CI LLVM in `test-various` builder
It was disabled because it needs `lld`, but since #104748 was merged it is no longer needed.
This will speed this test, since it no longer needs to build LLVM.
Recover from where clauses placed before tuple struct bodies
Open to any suggestions regarding the phrasing of the diagnostic.
Fixes#100790.
`@rustbot` label A-diagnostics
r? diagnostics
Note predicate span on `ImplDerivedObligation`
Seems obvious to point out the where-clause that introduces the `ImplDerivedObligation` :)
r? `@estebank`