use precalculated dominators in explain_borrow
This looks like the only place calculating dominators from the MIR body every time instead of using the ones stored on the `MirBorrowckCtxt`. For example, in rust-lang/rust#65131 a big generated function with a number of borrowck errors takes a few hours(!) recalculating the dominators while explaining the errors.
I don't know enough about this part of rustc codebase to know for sure that this change is correct, but no tests seem to fail as a result of this change in local testing.
`expand_pattern()` has two callsites. One of them needs arena
allocation, but the other does not.
This commit moves the arena allocation out of the function. This avoids
the allocation of many 4 KiB page arena chunks that only hold a single
small allocation. It reduces the number of bytes allocated by up to 2%
for various benchmarks, albeit without only a very small improvement in
runtime.
Rollup of 14 pull requests
Successful merges:
- #64603 (Reducing spurious unused lifetime warnings.)
- #64623 (Remove last uses of gensyms)
- #65235 (don't assume we can *always* find a return type hint in async fn)
- #65242 (Fix suggestion to constrain trait for method to be found)
- #65265 (Cleanup librustc mir err codes)
- #65293 (Optimize `try_expand_impl_trait_type`)
- #65307 (Try fix incorrect "explicit lifetime name needed")
- #65308 (Add long error explanation for E0574)
- #65353 (save-analysis: Don't ICE when resolving qualified type paths in struct members)
- #65389 (Return `false` from `needs_drop` for all zero-sized arrays.)
- #65402 (Add troubleshooting section to PGO chapter in rustc book.)
- #65425 (Optimize `BitIter`)
- #65438 (Organize `never_type` tests)
- #65444 (Implement AsRef<[T]> for List<T>)
Failed merges:
- #65390 (Add long error explanation for E0576)
r? @ghost
Add troubleshooting section to PGO chapter in rustc book.
- Adds a note about using `-pgo-warn-missing-function` in order to spot mistakes in PGO setup.
- Mentions cargo symbol name issue fixed in 1.39.
Nominating for backport.
r? @alexcrichton
Return `false` from `needs_drop` for all zero-sized arrays.
Resolves#65348.
This changes the result of the `needs_drop` query from `true` to `false` for types such as `[Box<i32>; 0]`. I believe this change to be sound because a zero-sized array can never actually hold a value. This is an elegant way of resolving #65348 and #64945, but obviously it has much broader implications.
save-analysis: Don't ICE when resolving qualified type paths in struct members
Previously, we failed since we use `qpath_res` via typeck tables - when using those we need to pass in a HirId that's local to the definition path the tables are rooted at (otherwise we risk frame of reference mismatch and an assertion against invalid lookup).
In this case we can't get typeck tables for struct definition because it has no body, however the struct member type node is rooted under the struct definition and so we can't really do anything about it in terms of traversal.
Instead, we try to "nest" the tables as always but change the default behaviour to use empty typeck tables rather than silently trying to use the current ones. This does work as we expect and for prior art, we use the same approach in the [privacy](7bc94cc3c2/src/librustc_privacy/lib.rs (L332-L341)) [pass](7bc94cc3c2/src/librustc_privacy/lib.rs (L1007-L1028)).
Fixes#64659.
Fixes#64821.
r? @nikomatsakis (since this changes the default behaviour introduced in d7d3f197f6)
Optimize `try_expand_impl_trait_type`
A lot of time was being spent expanding some large `impl Future` types in fuchsia. This PR takes the number of types being visited in one expansion from >3 billion to about a thousand, and eliminates the compile time regression in https://github.com/rust-lang/rust/issues/65147 (in fact, compile times are better than they were before).
Thanks to @Mark-Simulacrum for helping identify the issue and to @matthewjasper for suggesting this change.
Fixes#65147.
r? @matthewjasper,@nikomatsakis
Cleanup librustc mir err codes
Three things are done in this PR:
* Sort error codes
* Uncomment an error code long error explanation (they should **never** be commented)
* Unify explanations
don't assume we can *always* find a return type hint in async fn
In particular, we sometimes cannot if there is an earlier error.
Fixes#65159
r? @cramertj, who reviewed the original PR
Remove last uses of gensyms
Underscore bindings now use unique `SyntaxContext`s to avoid collisions. This was the last use of gensyms in the compiler, so this PR also removes them.
closes#49300
cc #60869
r? @petrochenkov
This splits out a rustc-dev component with the compiler crates, and
keeps the status quo of default installed files on nightly. The default
changing to not install compiler libraries by default is left for a
future pull request.
However, on stable and beta, this does remove the compiler libraries
from the set of libraries installed by default, as they are never needed
there (per our stability story, they "cannot" be used).