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 commit removes an `Option` check in `BitIter::next()`, avoids
calling `trailing_zeros()` when it's not necessary, and avoids the need
for `enumerate()`. This gives a tiny (0.2%) instruction count win on a
couple of benchmarks.
The commit also adds some comments, which is good because this iteration
code is moderately complex.
add test to for the fix
add descriptive text for the fix
simplified code logics
update descriptive comments
update to cope with the tidyness requirement
merged commit suggestions
Co-Authored-By: varkor <github@varkor.com>
truncated redundant comments
update to cope with tidy-check
Refactor: Rename `db` locals to `diag`
https://github.com/rust-lang/rust/pull/64272 replaced `DiagnosticBuilder` with `Diagnostic` in some places. This PR just renames the db variable from `db` to `diag` where it wasn't renamed.
r? @Mark-Simulacrum
Remove custom `PartialEq` impls for `LocalInternedString`.
This is on-trend with the recent changes simplifying
`LocalInternedString` and reducing its use.
r? @petrochenkov