rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
93.58k stars 12.05k forks source link

Improve `rustc_parse::Parser`'s debuggability #124779

Closed workingjubilee closed 1 week ago

workingjubilee commented 1 week ago

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.

rustbot commented 1 week ago

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rust-log-analyzer commented 1 week ago

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot) ```plain Compiling rustc_attr v0.0.0 (/checkout/compiler/rustc_attr) Compiling rustc_query_system v0.0.0 (/checkout/compiler/rustc_query_system) Compiling rustc_parse v0.0.0 (/checkout/compiler/rustc_parse) Compiling rustc_middle v0.0.0 (/checkout/compiler/rustc_middle) error[E0369]: binary operation `==` cannot be applied to type `Recovery` | | 1570 | if parser.recovery == Recovery::Forbidden { | --------------- ^^ ------------------- Recovery | Recovery | note: an implementation of `PartialEq` might be missing for `Recovery` --> compiler/rustc_parse/src/parser/mod.rs:125:1 --> compiler/rustc_parse/src/parser/mod.rs:125:1 | 125 | pub enum Recovery { | ^^^^^^^^^^^^^^^^^ must implement `PartialEq` help: consider annotating `Recovery` with `#[derive(PartialEq)]` | 125 + #[derive(PartialEq)] 126 | pub enum Recovery { For more information about this error, try `rustc --explain E0369`. error: could not compile `rustc_parse` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... ```
compiler-errors commented 1 week ago

@bors r+

bors commented 1 week ago

:pushpin: Commit 5e67a3783c89ebb1f611e0351c9a36a579e49cec has been approved by compiler-errors

It is now in the queue for this repository.

bors commented 1 week ago

:hourglass: Testing commit 5e67a3783c89ebb1f611e0351c9a36a579e49cec with merge 5ce96b1d0f6b5093955e7b6a70dfd877395c1d73...

bors commented 1 week ago

:sunny: Test successful - checks-actions Approved by: compiler-errors Pushing 5ce96b1d0f6b5093955e7b6a70dfd877395c1d73 to master...

rust-timer commented 1 week ago

Finished benchmarking commit (5ce96b1d0f6b5093955e7b6a70dfd877395c1d73): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment. | | mean | range | count | |:----------------------------------:|:----:|:------------:|:-----:| | Regressions ❌
(primary) | - | - | 0 | | Regressions ❌
(secondary) | 3.2% | [3.2%, 3.2%] | 1 | | Improvements ✅
(primary) | - | - | 0 | | Improvements ✅
(secondary) | - | - | 0 | | All ❌✅ (primary) | - | - | 0 |

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 676.869s -> 676.306s (-0.08%) Artifact size: 315.94 MiB -> 315.93 MiB (-0.00%)