Improve `rustc_parse::Parser`'s debuggability
The main event is the final commit where I add `Parser::debug_lookahead`. Everything else was basically cleaning up things that bugged me (debugging, as it were) until I felt comfortable enough to actually work on it.
The motivation is that it's annoying as hell to try to figure out how the debug infra works in rustc without having basic queries like `debug!(?parser);` come up "empty". However, Parser has a lot of fields that are mostly irrelevant for most debugging, like the entire ParseSess. I think `Parser::debug_lookahead` with a capped lookahead might be fine as a general-purpose Debug impl, but this adapter version was suggested to allow more choice, and admittedly, it's a refined version of what I was already handrolling just to get some insight going.
To decide if internal items should be inlined in a doc page,
check if the crate is itself internal, rather than if it has
the rustc_private feature flag. The standard library uses
internal items, but is not itself internal and should not show
internal items on its docs pages.
I tried debugging a parser-related issue but found it annoying to not be
able to easily peek into the Parser's token stream.
Add a convenience fn that offers an opinionated view into the parser,
but one that is useful for answering basic questions about parser state.
coverage: Branch coverage support for let-else and if-let
This PR adds branch coverage instrumentation for let-else and if-let, including let-chains.
This lifts two of the limitations listed at #124118.
This commit changes the new `wasm32-wasip2` target to being PIC by
default rather than the previous non-PIC by default. This change is
intended to make it easier for the standard library to be used in a
shared object in its precompiled form. This comes with a hypothetical
modest slowdown but it's expected that this is quite minor in most use
cases or otherwise wasm compilers and/or optimizing runtimes can elide
the cost.
Do not ICE on `AnonConst`s in `diagnostic_hir_wf_check`
Fixes#122989
Below is the snippet from #122989 that ICEs:
```rust
trait Traitor<const N: N<2> = 1, const N: N<2> = N> {
fn N(&N) -> N<2> {
M
}
}
trait N<const N: Traitor<2> = 12> {}
```
The `AnonConst` that triggers the ICE is the `2` in the param `const N: N<2> = 1`. The currently existing code in `diagnostic_hir_wf_check` deals only with `AnonConst`s that are default values of some param, but the `2` is not a default value. It is just an `AnonConst` HIR node inside a `TraitRef` HIR node corresponding to `N<2>`. Therefore the existing code cannot handle it and this PR ensures that it does.
Rollup of 5 pull requests
Successful merges:
- #124738 (rustdoc: dedup search form HTML)
- #124827 (generalize hr alias: avoid unconstrainable infer vars)
- #124832 (narrow down visibilities in `rustc_parse::lexer`)
- #124842 (replace another Option<Span> by DUMMY_SP)
- #124846 (Don't ICE when we cannot eval a const to a valtree in the new solver)
r? `@ghost`
`@rustbot` modify labels: rollup
This commit fixes several issues in the fuchsia-test-runner.py script:
1. Migrate from `pm` to `ffx` for package management, as `pm` is now
deprecated. Furthermore, the `pm` calls used in this script no longer
work at Fuchsia's HEAD. This is the largest change in this commit, and
impacts all steps around repository management (creation and
registration of the repo, as well as package publishing).
2. Allow for `libtest` to be either statically or dynamically linked.
The script assumed it was dynamically linked, but the current Rust
behavior at HEAD is to statically link it.
3. Minor cleanup to use `ffx --machine json` rather than string parsing.
4. Minor cleanup to the docs around the script.
Don't ICE when we cannot eval a const to a valtree in the new solver
Use `const_eval_resolve` instead of `try_const_eval_resolve` because naming aside, the former doesn't ICE when a value can't be evaluated to a valtree.
r? lcnr
rustdoc: dedup search form HTML
This change constructs the search form HTML using JavaScript, instead of plain HTML. It uses a custom element because
- the [parser]'s insert algorithm runs the connected callback synchronously, so we won't get layout jank
- it requires very little HTML, so it's a real win in size
[parser]: https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
This shrinks the standard library by about 60MiB, by my test.
There should be no visible changes. Just use less disk space.
never patterns: lower never patterns to `Unreachable` in MIR
This lowers a `!` pattern to "goto Unreachable". Ideally I'd like to read from the place to make it clear that the UB is coming from an invalid value, but that's tricky so I'm leaving it for later.
r? `@compiler-errors` how do you feel about a lil bit of MIR lowering
Correct the const stabilization of `last_chunk` for slices
`<[T]>::last_chunk` should have become const stable as part of <https://github.com/rust-lang/rust/pull/117561>. Update the const stability gate to reflect this.
f16::is_sign_{positive,negative} were feature-gated on f128
`f16::is_sign_positive` and `f16::is_sign_negative` were feature-gated on `"f128"` instead of `"f16"`.
Implement lldb formatter for "clang encoded" enums (LLDB 18.1+) (V3)
This is a redo of PR (#124458) which was approved previously but force-pushed out. Then a V2 (#124745) failed `debuginfo\msvc-pretty-enums.rs` test during merge.
I've fixed the test and checked it to pass on Windows with `.\x.ps1 test .\tests\debuginfo\msvc-pretty-enums.rs`
Below is the original summary:
## Summary:
fixes#79530
I landed a fix last year to enable `DW_TAG_variant_part` encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information.
This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way.
I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums.
## Test Plan:
ran tests `./x test tests/debuginfo/`. Also tested manually in LLDB CLI and LLDB VSCode
## Other Thoughs:
A better approach would probably be adopting [formatters from codelldb](https://github.com/vadimcn/codelldb/blob/master/formatters/rust.py). There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.
Update cc crate for bootstrap to v1.0.97
Reason:
In order to build the Windows version of the Rust toolchain for the Android platform, the following patch to the cc is crate is required to avoid incorrectly determining that we are building with the Android NDK: 57853c4bf8
This patch is present in version 1.0.80 and newer versions of the cc crate. The rustc source distribution currently has 3 different versions of cc in the vendor directory, only one of which has the necessary fix.
We (the Android Rust toolchain) are currently maintaining local patches to upgrade the cc crate dependency versions, which we would like to upstream.
Furthermore, beyond the specific reason, the cc crate in bootstrap is currently pinned at an old version due to problems in the past when trying to update it. It is worthwhile to figure out and resolve these problems so we can keep the dependency up-to-date.
Other fixes:
As of cc v1.0.78, object files are prefixed with a 16-character hash.
Update src/bootstrap/src/core/build_steps/llvm.rs to account for this to
avoid failures when building libunwind and libcrt. Note that while the hash
prefix was introduced in v1.0.78, in order to determine the names of the
object files without scanning the directory, we rely on the compile_intermediates
method, which was introduced in cc v1.0.86
As of cc v1.0.86, compilation on MacOS uses the -mmacosx-version-min flag.
A long-standing bug in the CMake rules for compiler-rt causes compilation
to fail when this flag is specified. So we add a workaround to suppress this
flag.
Updating to cc v1.0.91 and newer requires fixes to bootstrap unit tests.
The unit tests use targets named "A", "B", etc., which fail a validation
check introduced in 1.0.91 of the cc crate.
As of cc v1.0.74, the SDKROOT environment variable is used on Darwin if present,
regardless of whether it is for the correct platform or not. This is fixed in cc v1.0.97.
Adjust 64-bit ARM data layouts for LLVM update
LLVM has updated data layouts to specify `Fn32` on 64-bit ARM to avoid C++ accidentally underaligning functions when trying to comply with member function ABIs.
This should only affect Rust in cases where we had a similar bug (I don't believe we have one), but our data layout must match to generate code.
As a compatibility adaptatation, if LLVM is not version 19 yet, `Fn32` gets voided from the data layout.
See llvm/llvm-project#90415
`@rustbot` label: +llvm-main
cc `@krasimirgg`
r? `@durin42`
Adjust dbg.value/dbg.declare checks for LLVM update
https://github.com/llvm/llvm-project/pull/89799 changes llvm.dbg.value/declare intrinsics to be in a different, out-of-instruction-line representation. For example
call void `@llvm.dbg.declare(...)`
becomes
#dbg_declare(...)
Update tests accordingly to work with both the old and new way.
https://github.com/llvm/llvm-project/pull/89799 changes llvm.dbg.value/declare intrinsics to be in a different, out-of-instruction-line representation. For example
call void @llvm.dbg.declare(...)
becomes
#dbg_declare(...)
Update tests accordingly to work with both the old and new way.
Reason:
In order to build the Windows version of the Rust toolchain for the Android platform, the following patch to the cc is crate is required to avoid incorrectly determining that we are building with the Android NDK: 57853c4bf8
This patch is present in version 1.0.80 and newer versions of the cc crate. The rustc source distribution currently has 3 different versions of cc in the vendor directory, only one of which has the necessary fix.
We (the Android Rust toolchain) are currently maintaining local patches to upgrade the cc crate dependency versions, which we would like to upstream.
Furthermore, beyond the specific reason, the cc crate in bootstrap is currently pinned at an old version due to problems in the past when trying to update it. It is worthwhile to figure out and resolve these problems so we can keep the dependency up-to-date.
Other fixes:
As of cc v1.0.78, object files are prefixed with a 16-character hash.
Update src/bootstrap/src/core/build_steps/llvm.rs to account for this to
avoid failures when building libunwind and libcrt. Note that while the hash
prefix was introduced in v1.0.78, in order to determine the names of the
object files without scanning the directory, we rely on the compile_intermediates
method, which was introduced in cc v1.0.86
As of cc v1.0.86, compilation on MacOS uses the -mmacosx-version-min flag.
A long-standing bug in the CMake rules for compiler-rt causes compilation
to fail when this flag is specified. So we add a workaround to suppress this
flag.
Updating to cc v1.0.91 and newer requires fixes to bootstrap unit tests.
The unit tests use targets named "A", "B", etc., which fail a validation
check introduced in 1.0.91 of the cc crate.
Update books
## rust-lang/book
3 commits in d207d894cc5e1d496ab99beeacd1a420e5d4d238..bebcf527e67755a989a1739b7cfaa8f0e6b30040
2024-04-30 02:06:57 UTC to 2024-04-25 21:04:25 UTC
- [ch10-03] Fix wording change about mandatory type annotation (rust-lang/book#3904)
- Introduce handling for accessible/semantic note rendering in HTML (rust-lang/book#3907)
- Backport changes from print for ch7 (rust-lang/book#3901)
## rust-embedded/book
1 commits in aa7d4b0b4653ddb47cb1de2036d090ec2ba9dab1..17842ebb050f62e40a4618edeb8e8ee86e758707
2024-05-01 13:23:40 UTC to 2024-05-01 13:23:40 UTC
- Update embedded rust debugging section of tooling.md (rust-embedded/book#369)
## rust-lang/reference
1 commits in 5854fcc286557ad3ab34d325073d11d8118096b6..51817951d0d213a0011f82b62aae02c3b3f2472e
2024-04-27 17:54:45 UTC to 2024-04-27 17:54:45 UTC
- Add docs for `#[collapse_debuginfo]` attribute (rust-lang/reference#1468)
## rust-lang/rust-by-example
3 commits in 60d34b5fd33db1346f9aabfc0c9d0bda6c8e42be..229ad13b64d919b12e548d560f06d88963b25cd3
2024-05-06 00:15:45 UTC to 2024-04-24 18:29:38 UTC
- Missing import (rust-lang/rust-by-example#1841)
- Added missing word (rust-lang/rust-by-example#1838)
- Raw string literal can contain up to 255 #s according to Rust Reference (rust-lang/rust-by-example#1839)
## rust-lang/rustc-dev-guide
5 commits in 07425fed36b00e60341c5e29e28d37d40cbd4451..2d1947ff34d50ca46dfe242ad75531a4c429bb52
2024-05-06 06:48:21 UTC to 2024-04-28 18:31:21 UTC
- Add documentation for check-cfg by-default in UI tests (rust-lang/rustc-dev-guide#1966)
- Add documentation on Apple notification group (rust-lang/rustc-dev-guide#1964)
- Update CI documentation to avoid mentioning `expand-yaml-anchors` (rust-lang/rustc-dev-guide#1971)
- Rename `-Z verbose` to `-Z verbose-internals` (rust-lang/rustc-dev-guide#1968)
- typo traige->triage (rust-lang/rustc-dev-guide#1967)
borrowck: prepopulate opaque storage more eagerly
otherwise we ICE due to ambiguity when normalizing while computing implied bounds.
r? ``@compiler-errors``
Record impl args in the proof tree in new solver
Rather than rematching them during select.
Also use `ImplSource::Param` instead of `ImplSource::Builtin` for alias-bound candidates, so we don't ICE in `Instance::resolve`.
r? lcnr
Make check-cfg docs more user-friendly
This PR improves the `--check-cfg` to make them more user-friendly by:
- explaining the purpose of the feature
- removing the "form" jargon
- making it (bit) less formal and more "friendly"
- making the doc less cluttered
- and by fixing (the width and flags) of the examples
`@rustbot` label +F-check-cfg