Skip to content

Conversation

@JonathanBrouwer
Copy link
Contributor

Successful merges:

r? @ghost

Create a similar rollup

nicholasbishop and others added 30 commits January 11, 2026 23:26
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
rust-bors bot pushed a commit that referenced this pull request Jan 19, 2026
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
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 19, 2026

☀️ Try build successful (CI)
Build commit: a332e0b (a332e0b5b03b1dfea65c1bf3efb24177c3b67889, parent: d940e56841ddcc05671ead99290e35ff2e98369f)

@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 20, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 20, 2026

☀️ Test successful - CI
Approved by: JonathanBrouwer
Duration: 3h 15m 56s
Pushing 63f4513 to main...

@rust-bors rust-bors bot merged commit 63f4513 into rust-lang:main Jan 20, 2026
13 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 20, 2026
@github-actions
Copy link
Contributor

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 differences

Show 445 test diffs

Stage 0

  • lints::verify_lint_associated_const_elided_lifetime_117: [missing] -> pass (J0)
  • lints::verify_lint_associated_const_elided_lifetime_119: pass -> [missing] (J0)
  • lints::verify_lint_atomic_ordering_fence_97: pass -> [missing] (J0)
  • lints::verify_lint_atomic_ordering_invalid_96: [missing] -> pass (J0)
  • lints::verify_lint_atomic_ordering_load_93: [missing] -> pass (J0)
  • lints::verify_lint_attr_crate_level_142: pass -> [missing] (J0)
  • lints::verify_lint_confusable_identifier_pair_76: [missing] -> pass (J0)
  • lints::verify_lint_dangling_pointers_from_locals_72: [missing] -> pass (J0)
  • lints::verify_lint_dangling_pointers_from_temporaries_71: [missing] -> pass (J0)
  • lints::verify_lint_deprecated_lint_name_70: pass -> [missing] (J0)
  • lints::verify_lint_doc_alias_duplicated_128: pass -> [missing] (J0)
  • lints::verify_lint_doc_auto_cfg_expects_hide_or_show_129: pass -> [missing] (J0)
  • lints::verify_lint_doc_auto_cfg_hide_show_expects_list_131: pass -> [missing] (J0)
  • lints::verify_lint_doc_auto_cfg_wrong_literal_138: pass -> [missing] (J0)
  • lints::verify_lint_doc_test_literal_139: [missing] -> pass (J0)
  • lints::verify_lint_doc_test_unknown_138: [missing] -> pass (J0)
  • lints::verify_lint_doc_test_unknown_140: pass -> [missing] (J0)
  • lints::verify_lint_doc_unknown_any_137: pass -> [missing] (J0)
  • lints::verify_lint_doc_unknown_include_131: [missing] -> pass (J0)
  • lints::verify_lint_doc_unknown_spotlight_134: pass -> [missing] (J0)
  • lints::verify_lint_identifier_uncommon_codepoints_77: pass -> [missing] (J0)
  • lints::verify_lint_ignored_unless_crate_specified_70: [missing] -> pass (J0)
  • lints::verify_lint_implicit_sysroot_crate_import_69: pass -> [missing] (J0)
  • lints::verify_lint_missing_gpu_kernel_export_name_91: [missing] -> pass (J0)
  • lints::verify_lint_missing_gpu_kernel_export_name_93: pass -> [missing] (J0)
  • lints::verify_lint_mixed_script_confusables_77: [missing] -> pass (J0)
  • lints::verify_lint_multiple_supertrait_upcastable_75: pass -> [missing] (J0)
  • lints::verify_lint_non_fmt_panic_braces_78: [missing] -> pass (J0)
  • lints::verify_lint_noop_method_call_79: [missing] -> pass (J0)
  • lints::verify_lint_noop_method_call_81: pass -> [missing] (J0)
  • lints::verify_lint_overflowing_literal_85: [missing] -> pass (J0)
  • lints::verify_lint_overflowing_literal_87: pass -> [missing] (J0)
  • lints::verify_lint_overflowing_uint_84: [missing] -> pass (J0)
  • lints::verify_lint_path_statement_no_effect_100: [missing] -> pass (J0)
  • lints::verify_lint_raw_prefix_111: [missing] -> pass (J0)
  • lints::verify_lint_reserved_prefix_110: [missing] -> pass (J0)
  • lints::verify_lint_reserved_prefix_112: pass -> [missing] (J0)
  • lints::verify_lint_suspicious_double_ref_deref_82: pass -> [missing] (J0)
  • lints::verify_lint_untranslatable_diag_67: pass -> [missing] (J0)
  • lints::verify_lint_unused_closure_98: [missing] -> pass (J0)
  • lints::verify_lint_unused_comparisons_89: [missing] -> pass (J0)
  • lints::verify_lint_unused_crate_dependency_110: pass -> [missing] (J0)
  • lints::verify_lint_unused_duplicate_124: [missing] -> pass (J0)
  • lints::verify_lint_unused_import_braces_101: [missing] -> pass (J0)
  • lints::verify_lint_unused_import_braces_103: pass -> [missing] (J0)
  • lints::verify_lint_unused_result_97: [missing] -> pass (J0)
  • lints::verify_lint_variant_size_differences_92: [missing] -> pass (J0)
  • lints::verify_lint_variant_size_differences_94: pass -> [missing] (J0)
  • transmute::verify_lint_undefined_transmute_144: pass -> [missing] (J0)

Stage 1

  • [ui] tests/ui-fulldeps/internal-lints/diagnostics.rs: ignore (ignored when the bootstrapping stage is stage1) -> [missing] (J0)
  • [ui] tests/ui/parser/macro/kw-in-item-pos-recovery-151238.rs: [missing] -> pass (J0)
  • [ui] tests/ui/trimmed-paths/doc-hidden.rs: [missing] -> pass (J0)
  • lints::verify_lint_atomic_ordering_fence_95: [missing] -> pass (J1)
  • lints::verify_lint_atomic_ordering_fence_97: pass -> [missing] (J1)
  • lints::verify_lint_atomic_ordering_invalid_98: pass -> [missing] (J1)
  • lints::verify_lint_atomic_ordering_load_93: [missing] -> pass (J1)
  • lints::verify_lint_atomic_ordering_load_95: pass -> [missing] (J1)
  • lints::verify_lint_atomic_ordering_store_96: pass -> [missing] (J1)
  • lints::verify_lint_attr_crate_level_140: [missing] -> pass (J1)
  • lints::verify_lint_bad_opt_access_66: [missing] -> pass (J1)
  • lints::verify_lint_bad_opt_access_68: pass -> [missing] (J1)
  • lints::verify_lint_dangling_pointers_from_locals_74: pass -> [missing] (J1)
  • lints::verify_lint_dangling_pointers_from_temporaries_71: [missing] -> pass (J1)
  • lints::verify_lint_deprecated_lint_name_70: pass -> [missing] (J1)
  • lints::verify_lint_doc_auto_cfg_hide_show_expects_list_129: [missing] -> pass (J1)
  • lints::verify_lint_doc_auto_cfg_wrong_literal_138: pass -> [missing] (J1)
  • lints::verify_lint_doc_invalid_132: pass -> [missing] (J1)
  • lints::verify_lint_doc_test_literal_139: [missing] -> pass (J1)
  • lints::verify_lint_doc_test_takes_list_139: pass -> [missing] (J1)
  • lints::verify_lint_doc_test_unknown_138: [missing] -> pass (J1)
  • lints::verify_lint_doc_unknown_include_131: [missing] -> pass (J1)
  • lints::verify_lint_doc_unknown_passes_135: pass -> [missing] (J1)
  • lints::verify_lint_doc_unknown_spotlight_132: [missing] -> pass (J1)
  • lints::verify_lint_identifier_non_ascii_char_76: pass -> [missing] (J1)
  • lints::verify_lint_ill_formed_attribute_input_111: pass -> [missing] (J1)
  • lints::verify_lint_improper_gpu_kernel_arg_90: [missing] -> pass (J1)
  • lints::verify_lint_incorrect_do_not_recommend_args_141: [missing] -> pass (J1)
  • lints::verify_lint_invalid_target_124: pass -> [missing] (J1)
  • lints::verify_lint_multiple_supertrait_upcastable_73: [missing] -> pass (J1)
  • lints::verify_lint_multiple_supertrait_upcastable_75: pass -> [missing] (J1)
  • lints::verify_lint_only_cast_u8_to_char_85: pass -> [missing] (J1)
  • lints::verify_lint_overflowing_uint_84: [missing] -> pass (J1)
  • lints::verify_lint_overflowing_uint_86: pass -> [missing] (J1)
  • lints::verify_lint_pass_by_value_82: [missing] -> pass (J1)
  • lints::verify_lint_raw_prefix_111: [missing] -> pass (J1)
  • lints::verify_lint_raw_prefix_113: pass -> [missing] (J1)
  • lints::verify_lint_reserved_prefix_110: [missing] -> pass (J1)
  • lints::verify_lint_suspicious_double_ref_clone_81: [missing] -> pass (J1)
  • lints::verify_lint_suspicious_double_ref_clone_83: pass -> [missing] (J1)
  • lints::verify_lint_too_large_char_cast_89: pass -> [missing] (J1)
  • lints::verify_lint_unit_bindings_104: [missing] -> pass (J1)
  • lints::verify_lint_unused_allocation_104: pass -> [missing] (J1)
  • lints::verify_lint_unused_closure_98: [missing] -> pass (J1)
  • lints::verify_lint_unused_comparisons_91: pass -> [missing] (J1)
  • lints::verify_lint_unused_coroutine_101: pass -> [missing] (J1)
  • lints::verify_lint_unused_result_99: pass -> [missing] (J1)
  • lints::verify_lint_variant_size_differences_94: pass -> [missing] (J1)
  • transmute::verify_lint_undefined_transmute_142: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/parser/missing-closing-generics-bracket.rs: [missing] -> pass (J2)
  • [ui] tests/ui/reserved/meta-is-not-reserved.rs: [missing] -> pass (J2)

(and 230 additional test diffs)

Additionally, 115 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 63f4513795b198d034f5d19962659ea488163755 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 5346.8s -> 3804.4s (-28.8%)
  2. dist-aarch64-linux: 8871.0s -> 6679.3s (-24.7%)
  3. x86_64-msvc-1: 8445.1s -> 9476.6s (+12.2%)
  4. test-various: 7716.6s -> 6834.6s (-11.4%)
  5. dist-aarch64-apple: 6912.3s -> 7673.3s (+11.0%)
  6. dist-i586-gnu-i586-i686-musl: 5469.7s -> 4878.3s (-10.8%)
  7. x86_64-gnu-llvm-20-1: 4508.0s -> 4056.2s (-10.0%)
  8. x86_64-gnu-tools: 3830.8s -> 3458.1s (-9.7%)
  9. dist-aarch64-llvm-mingw: 6644.7s -> 6030.4s (-9.2%)
  10. dist-riscv64-linux: 5007.2s -> 4561.3s (-8.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#148623 Ignore #[doc(hidden)] items when computing trimmed paths … e83b9d32fba473d1eeaada48f1086a7dbda51297 (link)
#150550 Miscellaneous cleanups to borrowck related code f6790fd18138ba8384b727d2f88d5199d8b9392c (link)
#150879 Remove the diagnostic lints d14532dcc8ebe03d3c0aa17e657fdc2f4fdc8616 (link)
#150895 rustc_errors: Add (heuristic) Syntax Highlighting for `rust… 28b763ddf18fadebc608ec4246f2ab842e31646a (link)
#150987 remote-test-server: Fix header in batch mode b58430c139e79be35993a56002f965907880ffae (link)
#151004 std: implement sleep_until on Apple platforms e4fd3d53e5ab9bebb8154d6856fca64a52ad1a6f (link)
#151045 Simplify some literal-value negations with `u128::wrapping_… fd855c20f1219f01cfd40f2ec4deccbcd0288aae (link)
#151119 Support pointers in type reflection 75d75fefe04a105ac8e5a6f54cb8887092cd9018 (link)
#151171 Do not recover from Trait() if generic list is unterminat… c06395177221e05d20514a7bb8ca613a211ebc21 (link)
#151231 HIR typeck cleanup: clarify and re-style check_expr_unop 3155f51a593ee9975c7c04f647e8dcfd3ba18e0e (link)
#151249 Parse ident with allowing recovery when trying to diagnose c2ee9473b133b82163bcb99b4171b3571a70a733 (link)
#151295 THIR patterns: Use ty::Value in more places throughout `c… 924c41e59c372b130ad8741b951fbcf96561155c (link)
#151326 Remove DiagMessage::Translated in favour of `DiagMessage:… f23a8d22039e13fd285a44acff7607a69b07b453 (link)
#151361 add test for issue 61463 95a46615d2d2a01635885eb6258579c5e6c7e4cc (link)
#151371 Add S-blocked to labels_blocking_approval 840382d9f943aa198bc6adef61d3066419e165f3 (link)

previous master: d940e56841

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (63f4513): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.6% [0.1%, 20.1%] 20
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 1

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.

mean range count
Regressions ❌
(primary)
1.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
3.5% [3.0%, 4.0%] 3
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
-5.6% [-5.6%, -5.6%] 1
All ❌✅ (primary) -0.1% [-2.1%, 1.8%] 2

Cycles

Results (primary 4.2%, secondary 5.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
4.2% [2.1%, 10.0%] 22
Regressions ❌
(secondary)
5.8% [1.8%, 19.6%] 23
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) 4.2% [2.1%, 10.0%] 22

Binary size

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

Bootstrap: 473.058s -> 474.28s (0.26%)
Artifact size: 383.29 MiB -> 383.30 MiB (0.00%)

@Kobzol
Copy link
Member

Kobzol commented Jan 20, 2026

The regression comes from #148623, continuing there.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic merged-by-bors This PR was explicitly merged by bors. O-unix Operating system: Unix-like perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. rollup A PR which is a rollup T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.