-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Rollup of 15 pull requests #151381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rollup of 15 pull requests #151381
Conversation
In rust-lang#119999, the length field of the header was changed from 4 bytes to 8. One of the headers in `batch_copy` was missed though, so it sends the wrong size. Fix by switching to `create_header` in that spot too.
If we encounter `fn foo<T: Trait()`, the recovery logic would it as if `Trait` was intended to use the Fn-like trait syntax, but if we don't know for certain that we've parsed a full trait bound (`fn foo<T: Trait()>`), we bail from the recovery as more likely there could have been a missing closing `>` and the `(` corresponds to the start of the fn parameter list.
`oprnd_t` was used both for the type of the operand of a unary operator and for the type of the operator expression as a whole. Now it's only used for the operand's type.
A test for the issue where the variable meta is mistakenly treated as a reserved keyword.
This commit adds a heuristics-based syntax highlighter for the `rustc --explain` command. It uses `rsutc_lexer`'s lexer to parse input in tokens, and matches on them to determine their color.
…e_diagnostic` throughout the codebase This PR was mostly made by search&replacing
Ignore `#[doc(hidden)]` items when computing trimmed paths for printing The `trimmed_def_paths` query examines all items in the current crate, and all pub items in immediate-dependency crates (including the standard library), to see which item names are unique and can therefore be printed unambiguously as a bare name without a module path. Currently that query has no special handling for `#[doc(hidden)]` items, which has two consequences: - Hidden names can be considered unique, and will therefore be printed without a path, making it hard to find where that name is defined (since it normally isn't listed in documentation). - Hidden names can conflict with visible names that would otherwise be considered unique, causing diagnostics to mysteriously become more verbose based on internal details of other crates. This PR therefore makes the `trimmed_def_paths` query ignore external-crate items that are `#[doc(hidden)]`, along with their descendants. As a result, hidden item names are never considered unique for trimming, and no longer interfere with visible item names being considered unique. --- - Fixes rust-lang#148387.
Miscellaneous cleanups to borrowck related code r? lcnr
Remove the diagnostic lints Removes the `untranslatable_diagnostic` and `diagnostic_outside_of_impl` lints These lints are allowed for a while already. Per rust-lang/compiler-team#959, we no longer want to enforce struct diagnostics for all usecases, so this is no longer useful. r? @Kivooeo I recommend reviewing commit by commit (also feel free to wait with reviewing until the MCP is accepted) @rustbot +S-blocked Blocked by rust-lang/compiler-team#959
rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain` This PR adds a feature that enables `rustc --explain <error>` to have syntax highlighted code blocks. Due to performance, size and complexity constraints, the highlighter is very heuristc, relying on conventions for capitalizations and such to infer what an identifier represents. The details for the implementation are specified below. # Changes 1. Change `term::entrypoint` to `term::entrypoint_with_formatter`, which takes an optional third argument, which is a function pointer to a formatter. ([compiler/rustc_errors/src/markdown/mod.rs](https://github.com/rust-lang/rust/compare/main...JayanAXHF:rust:rustc_colored_explain?expand=1#diff-a6e139cadbc2e6922d816eb08f9e2c7b48304d09e6588227e2b70215c4f0725c)) 2. Change `MdStream::write_anstream_buf` to be a wrapper around a new function, `MdStream::write_anstream_buf_with_formatter`, which takes a function pointer to a formatter. ([compiler/rustc_errors/src/markdown/mod.rs](https://github.com/rust-lang/rust/compare/main...JayanAXHF:rust:rustc_colored_explain?expand=1#diff-a6e139cadbc2e6922d816eb08f9e2c7b48304d09e6588227e2b70215c4f0725c)) 3. Change [`compiler/rustc_driver_impl/src/lib.rs`](https://github.com/rust-lang/rust/compare/main...JayanAXHF:rust:rustc_colored_explain?expand=1#diff-39877a2556ea309c89384956740d5892a59cef024aa9473cce16bbdd99287937) to call `MdStream::write_anstream_buf_with_formatter` instead of `MdStream::write_anstream_buf`. 4. Add a `compiler/rustc_driver_impl/src/highlighter.rs` file, which contains the actual syntax highlighter. # Implementation Details 1. The highlighter starts from the `highlight` function defined in `compiler/rustc_driver_impl/src/highlighter.rs`. It creates a new instance of the `Highlighter` struct, and calls its `highlight_rustc_lexer` function to start highlighting. 2. The `highlight_rustc_lexer` function uses `rustc_lexer` to lex the code into `Token`s. `rustc_lexer` was chosen since it preserves the newlines after scanning. 3. Based on the kind of token (`TokenKind`), we color the corresponding lexeme. ## Highlighter Implementation ### Identifiers 1. All identifiers that match a (non-exhaustive and minimal) list of keywords are coloured magenta. 2. An identifier that begins with a capital letter is assumed as a type. There is no distinction between a `Trait` and a type, since that would involve name resolution, and the parts of `rustc` that perform name resolution on code do not preserve the original formatting. (An attempt to use `rustc_parse`'s lexer and `TokenStream` was made, which was then printed with the pretty printer, but failed to preserve the formatting and was generally more complex to work with) 3. An identifier that is immediately followed by a parenthesis is recognized as a function identifier, and coloured blue. ## Literals 5. A `String` literal (or its corresponding `Raw`, `C` and `Byte` versions) is colored green. 6. All other literals are colored bright red (orange-esque) ## Everything Else Everything else is colored bright white and dimmed, to create a grayish colour. --- # Demo <img width="1864" height="2136" alt="image" src="https://github.com/user-attachments/assets/b17d3a71-e641-4457-be85-5e5b1cea2954" /> <caption> Command: <code>rustc --explain E0520</code> </caption> --- This description was not generated by an LLM (:p) cc: @bjorn3
Rollup of 15 pull requests try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1 try-job: test-various try-job: armhf-gnu try-job: aarch64-apple try-job: x86_64-gnu-llvm-20-3 try-job: dist-various-2
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing d940e56 (parent) -> 63f4513 (this PR) Test differencesShow 445 test diffsStage 0
Stage 1
Stage 2
(and 230 additional test diffs) Additionally, 115 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 63f4513795b198d034f5d19962659ea488163755 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
📌 Perf builds for each rolled up PR:
previous master: d940e56841 In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
|
Finished benchmarking commit (63f4513): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.1%, secondary 1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 4.2%, secondary 5.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 473.058s -> 474.28s (0.26%) |
Successful merges:
#[doc(hidden)]items when computing trimmed paths for printing #148623 (Ignore#[doc(hidden)]items when computing trimmed paths for printing)rustc --explain#150895 (rustc_errors: Add (heuristic) Syntax Highlighting forrustc --explain)sleep_untilon Apple platforms #151004 (std: implementsleep_untilon Apple platforms)u128::wrapping_neg#151045 (Simplify some literal-value negations withu128::wrapping_neg)Trait()if generic list is unterminated #151171 (Do not recover fromTrait()if generic list is unterminated)check_expr_unop#151231 (HIR typeck cleanup: clarify and re-stylecheck_expr_unop)ty::Valuein more places throughoutconst_to_pat#151295 (THIR patterns: Usety::Valuein more places throughoutconst_to_pat)DiagMessage::Translatedin favour ofDiagMessage::Str#151326 (RemoveDiagMessage::Translatedin favour ofDiagMessage::Str)S-blockedtolabels_blocking_approval#151371 (AddS-blockedtolabels_blocking_approval)r? @ghost
Create a similar rollup