Commit Graph

1290 Commits

Author SHA1 Message Date
Guillaume Gomez
9dc456a366 Remove usage of LintContext::span_lint in clippy 2026-03-05 23:53:53 +01:00
Jonathan Brouwer
53ef4d297e Rollup merge of #153414 - JonathanBrouwer:translate_cleanup, r=Kivooeo
Rename translation -> formatting

Because there is no translation happening anymore

r? @Kivooeo
2026-03-04 19:30:42 +01:00
Jonathan Brouwer
1500680ba5 Rollup merge of #153401 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Migrationg of `LintDiagnostic` - part 7

Part of https://github.com/rust-lang/rust/issues/153099.

This PR removes the `LintDiagnostic` trait and proc-macro. \o/

r? @JonathanBrouwer
2026-03-04 19:30:40 +01:00
Jonathan Brouwer
1c44dbd580 Rollup merge of #152164 - mu001999-contrib:lint/unused_features, r=JonathanBrouwer
Lint unused features

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152164)*

Fixes rust-lang/rust#44232
Fixes rust-lang/rust#151752

---

This PR records used features through query side effect, then reports unsued features finally.
2026-03-04 19:30:36 +01:00
Jonathan Brouwer
d8092147fe Rename translation -> formatting 2026-03-04 17:47:24 +01:00
Guillaume Gomez
7ceb8ea1b0 Remove unused LintDiagnostic trait 2026-03-04 15:16:51 +01:00
Guillaume Gomez
56d636a762 Implement Diagnostic directly on Box<FnOnce...> 2026-03-03 22:14:53 +01:00
Guillaume Gomez
bd538f90fe Remove unused rustc_errors::LintDiagnosticBox trait 2026-03-03 17:21:41 +01:00
Guillaume Gomez
924748717b Implement Diagnostic trait for rustc_errors::DecorateDiagCompat 2026-03-03 17:21:16 +01:00
mu001999
d0a182f485 Remove unused features in compiler 2026-03-02 09:38:04 +08:00
Jonathan Brouwer
51f35d76a2 Pass DiagArgMap instead of FluentArgs into format_diag_message 2026-03-01 10:07:39 +01:00
Jonathan Brouwer
5ade46246e Move DiagArgMap to rustc_error_messages 2026-03-01 10:07:36 +01:00
Jonathan Brouwer
6e8d9c1242 Adjust uses of format_diag_message to remove unwrap 2026-02-28 18:46:53 +01:00
Jonathan Brouwer
5a18412c93 Remove TranslationError 2026-02-28 18:34:17 +01:00
Jonathan Brouwer
66cccfde99 Rollup merge of #147859 - cyrgani:nonfatal-tokenstream-parse, r=petrochenkov,JonathanBrouwer
reduce the amount of panics in `{TokenStream, Literal}::from_str` calls

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/147859)*

Before this PR, calling `TokenStream::from_str` or `Literal::from_str` with an invalid argument would always cause a compile error, even if the `TokenStream` is not used afterwards at all.
This PR changes this so it returns a `LexError` instead in some cases.

This is very theoretically a breaking change, but the doc comment on the impl already says
```
/// NOTE: some errors may cause panics instead of returning `LexError`. We reserve the right to
/// change these errors into `LexError`s later.
```

Fixes some cases of rust-lang/rust#58736.
2026-02-22 11:31:14 +01:00
Jonathan Brouwer
b0cdafbd4a Rollup merge of #152455 - JonathanBrouwer:remove_translation, r=jdonszelmann
Remove the translation `-Z` options and the `Translator` type.

This PR implements MCP https://github.com/rust-lang/compiler-team/issues/967

It is split up into individually reviewable commits, each commit passes tests:

* 6782119567 Removes the translation compiler options from the session
* 8f300d02fe Removes the now empty `Translator` type
* ab715c536f Renames `translate_message` to `format_diag_message`, as the function no longer does any translation
* 8bcbc3f766 Removes a section describing the removed compiler options from the rustc dev guide
2026-02-20 22:00:57 +01:00
Esteban Küber
37684bdfc5 Make all multipart suggestions verbose
The ShowAlways style of suggestions is usually easier to understand than the inline style.
2026-02-18 18:33:35 +00:00
Jonathan Brouwer
018a5efcf7 Rename inline_fluent! to msg! 2026-02-14 13:47:52 +01:00
Jonathan Brouwer
f1b935d08f Rollup merge of #152356 - JonathanBrouwer:inline_diag4, r=jdonszelmann
Improve the `inline_fluent!` macro

For https://github.com/rust-lang/rust/issues/151366

This PR turns `inline_fluent!` into a proc macro, so we can run validation on the messages in this macro :)
I started a thread here because I don't like the name of the macro, but that's for a future PR: [#t-compiler > Bikeshed the new &#96;inline_fluent!&#96; macro](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Bikeshed.20the.20new.20.60inline_fluent!.60.20macro/with/572646242)
2026-02-13 13:35:01 +01:00
mu001999
a07f837491 Remove unused features in compiler 2026-02-13 09:25:39 +08:00
cyrgani
f1c80f5988 reduce the amount of panics in {TokenStream, Literal}::from_str calls 2026-02-11 20:09:30 +00:00
Jonathan Brouwer
ab715c536f Rename translate_message to format_diag_message 2026-02-11 17:52:00 +01:00
Jonathan Brouwer
8f300d02fe Remove the Translator type 2026-02-11 17:52:00 +01:00
Lukas Bergdoll
2f3b952349 Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Jonathan Brouwer
6782119567 Remove the translation compiler options 2026-02-10 22:10:22 +01:00
Jonathan Brouwer
ea361287be Remove SubdiagMessage in favour of the identical DiagMessage 2026-02-10 09:13:45 +00:00
Jonathan Brouwer
6eb2a8fa9e Reformat existing error messages 2026-02-09 19:12:22 +01:00
Jonathan Brouwer
81d4214604 Remove fluent tests in rustc_error 2026-02-08 11:06:42 +01:00
Jonathan Brouwer
0db0acd699 Remove the fallback bundle 2026-02-08 11:06:42 +01:00
Jonathan Brouwer
ea8733133c Remove DiagMessage::FluentIdentifier 2026-02-08 10:33:29 +01:00
Jonathan Brouwer
d96d73fd86 Rollup merge of #152140 - bjorn3:driver_fixed_error_codes, r=jdonszelmann
Hard code the error code registry for custom drivers

And do some cleanups enabled by this.
2026-02-06 10:06:45 +01:00
Jonathan Brouwer
6782a190f2 Register functions in translation 2026-02-05 16:58:48 +01:00
Jonathan Brouwer
e55eb45661 Convert to inline diagnostics in rustc_errors 2026-02-05 12:14:48 +01:00
bjorn3
639cb694df Replace Registry type with a lazily initialized static
And move try_find_description to rustc_errors::codes.
2026-02-05 10:54:46 +00:00
bjorn3
1851937577 Hard code the error code registry for custom drivers 2026-02-04 21:21:15 +00:00
Jonathan Brouwer
f8fe49ea9e Introduce inline_fluent macro 2026-02-03 10:19:57 +01:00
Jonathan Brouwer
8927aa5738 Add inline syntax for diagnostic messages 2026-02-01 11:11:59 +01:00
Jacob Pratt
4a983e0900 Rollup merge of #151439 - Mark-Simulacrum:bootstrap-bump, r=nnethercote
Bump bootstrap compiler to 1.94

https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2026-01-22 00:37:43 -05:00
Mark Rousskov
3dc7a1f33b Bump stage0 2026-01-21 20:03:56 -05:00
bjorn3
3ccabc6a8d Remove old error emitter
This completes the transition to annotate-snippets
2026-01-21 12:14:51 +00:00
Jacob Pratt
2206d935f7 Rollup merge of #149209 - lto_refactors8, r=jackh726
Move LTO to OngoingCodegen::join

This will make it easier to in the future move all this code to link_binary.

Follow up to https://github.com/rust-lang/rust/pull/147810
Part of https://github.com/rust-lang/compiler-team/issues/908
2026-01-21 02:04:01 -05:00
Jonathan Brouwer
e8c3dd36f8 Rollup merge of #151326 - translated, r=davidtwco
Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`

This variant did not seem to be meaningfully different from `DiagMessage::Str`.
Am I missing something or was this just an oversight?

r? @davidtwco
2026-01-19 20:53:24 +01:00
Jonathan Brouwer
8a22babce9 Rollup merge of #150895 - rustc_colored_explain, r=Kivooeo
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
2026-01-19 20:53:21 +01:00
Jonathan Brouwer
f50f5dc494 Remove all usages of #[rustc_lint_diagnostics] 2026-01-19 17:39:54 +01:00
Jonathan Brouwer
0ee7d96253 Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
JayanAXHF
67c45b739a feat: added syntax highlighting for code blocks in rustc --explain
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.
2026-01-19 17:44:24 +05:30
Zalathar
7ec34defe9 Temporarily re-export assert_matches! to reduce stabilization churn 2026-01-19 18:26:53 +11:00
Jonathan Brouwer
ec787b07fd Remove DiagMessage::Translated in favour of DiagMessage::Str 2026-01-18 18:30:11 +01:00
Kivooeo
84f2854bc3 remove fixme & update stderr files 2025-12-16 13:23:48 +00:00
Kivooeo
6d6068f6c5 stabilize annotate-snippet as default formatter 2025-12-16 11:20:27 +00:00