Repository navigation
Diagnostic Translation #100717
Description
Activity
- addedC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.A-translationArea: Translation infrastructure, and migrating existing diagnostics to SessionDiagnosticArea: Translation infrastructure, and migrating existing diagnostics to SessionDiagnosticA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lints
on Aug 18, 2022 I took up
rustc_const_evalandrustc_expandfor the time being. Kudos for the further write-up! 🚀Reacted by David WoodI'm migrating
rustc_ast_loweringReacted by David WoodI'll probably look into migrating
rustc_inferReacted by David WoodI'm working on
rustc_parse.Reacted by David WoodI'm working on
rustc_typeck.Reacted by David WoodWorking on:
rustc_type_ir(zero diagnostic) - PR: Add diagnostics lints torustc_type_irmodule #100721rustc_symbol_mangling- PR: Migratesymbol_manglingmodule to new diagnostics structs #100831rustc_transmute(zero diagnostic) - PR: Add diagnostics lints torustc_transmutemodule (zero diags) #100842rustc_errors
Reacted by David Wood@5225225
rustc_logseems to be zero diagnostics as well. Do you want to add that to your PR?I'll continue to look for something unclaimed and small...
[ ]
rustc_transmute(currently being worked on by@nobody)🤷🏻♂️ I can't find this one. Should I be on a branch other than
master?Update your checkout. It's on
master, but I think it's fairly new. (I believe it's the safe transmute people)🤦🏻♂️ Thanks! I was working off a clone of my fork. I'm glad I discovered this now.
194 remaining items
Load more actionsI'm picking up the apparently abandoned
rustc_hir_typeckI'm taking
rustc_resolve, which seems abandoned.- added a commit that references this issue
on Jul 4, 2024 - added a commit that references this issue
on Aug 12, 2024 Important
Please see #132181 for the current status of the compiler's translatable diagnostics infrastructure.
- addedS-tracking-needs-deep-researchStatus: This feature needs deep research to solve design or implementation issues.Status: This feature needs deep research to solve design or implementation issues.S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.and removedS-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.
on Dec 25, 2024 - addedS-tracking-design-concernsStatus: There are blocking design concerns.Status: There are blocking design concerns.
on Feb 12, 2025 - marked [Bug]: rust diagnostic messages are not localized on macOS aarch64 #145964 as a duplicate of this issue
on Aug 28, 2025
Important
Please see #132181 for the current status of the compiler's translatable diagnostics infrastructure.
The Rust Diagnostics working group is leading an effort to add support for internationalization of error messages in the compiler, allowing the compiler to produce output in languages other than English. This issue tracks the current status of the effort, which was announced in the "Contribute to the diagnostic translation effort!" post on Inside Rust.
What's the current status?
Diagnostic translation will take a long time to be finished. At a high-level, there are four primary steps:
Implementing the initial translation infrastructure provides the groundwork that enables diagnostic messages to be made translatable at all. That initial infrastructure is largely completed - there might be some gaps that we'll discover and patch up as we continue - but it's almost all there.
Next, all of the diagnostics in rustc need to be modified so that they can be translatable. There's some bad news - that's a lot of work. But there's also some good news - that's a lot of highly parallelizable work that you can help with! It doesn't require any familiarity with the Rust compiler, just an eagerness to get involved.
How to get started?
It's very easy to get started, the process looks like the following:
Identifying diagnostics to migrate
Our goal is to migrate every diagnostic in the compiler to be translatable and to switch from using a "diagnostic builder" to using "diagnostic structs". That's a lot of diagnostics, so we're splitting the work up by module in the compiler so that nobody steps on anyone else's toes.
rustc_apfloatrustc_arenarustc_astrustc_ast_loweringrustc_ast_passesSessionDiagnosticand translatable messages (first part) #100694ast_passesto derive diagnostics #108456rustc_ast_prettyrustc_attrrustc_attrcrate diagnostics #100836rustc_borrowckrustc_borrowckdiagnostic #100798rustc_borrowckdiagnostics toSessionDiagnostic#100864region_errors.rs#100900mutability_errors.rsdiag-mig #101301Borrowck: diag migrate #101276descr#103469borrowckdiagnostic migration #101686rustc_borrowck#104055rustc_builtin_macrosrustc_builtin_macrostoSessionDiagnostic#101408rustc_builtin_macrosto diagnostic impls #110092rustc_codegen_craneliftrustc_codegen_gccrustc_codegen_llvmrustc_codegen_ssacodegen_ssato diagnostics structs - [Part 1] #102612codegen_ssato diagnostics structs - [Part 2] #103792rustc_const_evalrustc_data_structuresrustc_driverrustc_error_codesrustc_error_messagesrustc_errorsIntoDiagnosticconformance forTargetDataLayoutErrorsintorustc_errors#102684rustc_expandrustc_featurerustc_fs_utilrustc_graphvizrustc_hirrustc_hir_analysisrustc_hir_analysisto session diagnostic [Part One] #108434rustc_hir_prettyrustc_hir_typeckrustc_incrementalrustc_indexrustc_inferrustc_interfacerustc_interfacediagnostics #100808rustc_lexerrustc_lintrustc_linterrors toSessionDiagnostic#100776rustc_lintlint diagnostics #101138rustc_lint_defsrustc_llvmrustc_logrustc_macrosrustc_metadatarustc_middlerustc_middlediagnostic #101021rustc_mir_buildrustc_mir_builddiagnostics #100854 (continue from this partially completed work!)rustc_mir_dataflowrustc_monomorphizerustc_parserustc_parse_formatrustc_passesrustc_passesdiagnostics #100870dead_codelints to be translatable. #103397rustc_plugin_implrustc_plugin_impltoSessionDiagnostic#100768rustc_privacyrustc_query_implrustc_query_systemrustc_resolverustc_resolveto session diagnostic #123896rustc_save_analysisrustc_serializerustc_sessionrustc_sessionto useSessionDiagnostic- Pt. 1 #100753 101466rustc_smirrustc_spanrustc_symbol_manglingsymbol_manglingmodule to new diagnostics structs #100831rustc_targetrustc_trait_selection::traits::error_reporting::suggestionsrustc_trait_selection::traits::error_reporting::suggestionstoSessionDiagnostic#101466rustc_trait_selection(everything else)rustc_traitsrustc_transmuterustc_transmutemodule (zero diags) #100842rustc_ty_utilsrustc_ty_utilstoSessionDiagnostic#100735SessionDiagnostic#110095rustc_type_irrustc_type_irmodule #100721rustfmtclippyrustdocNote: Some of these crates might not have diagnostics in them, in which case we'll just enable our internal lints on them. Some might have lots and lots of work that we can split up further, let us know! If there aren't many crates left, then feel free to leave a comment asking if someone is still working on their crate (check if they commented or have put a PR up recently).
Once you've picked a module (leave a comment letting us know!), how do you find the diagnostics to migrate? We've created rustc-internal lints that you can apply to a module which will produce an error for every diagnostic that hasn't been migrated.
(an example of using these would just be adding them to the top of a file)
After adding these attributes, you can run
./x.py checkto build the compiler in check mode (just likecargo checkin another project). You'll notice a bunch of errors that will look something like these:There will be two errors for each diagnostic that isn't migrated:
err.label("an example label")instead oferr.label(fluent::example_label)fluent::example_labelcorresponds to a message in a "Fluent resource" which we can provide different versions of for each language.Diagnostic/Subdiagnosticimpls"DiagnosticorSubdiagnostic. One of our goals with this migration is to move all diagnostic emission logic into impls on structs, as it helps keep the compiler tidy and works towards other goals of the diagnostics working group.Diagnosticfor errors and warnings,LintDiagnosticfor lints, orSubdiagnsosticfor parts of an error/warning/lint) manually.We'll know we're finished when we can leave those attributes on every module in the compiler.
Migrate diagnostics
Okay, so you've got a diagnostic in front of you that you need to migrate.. now what?
A-translation.While migrating diagnostics, there might be cases you run into that we've not run across yet. Let us know in Zulip, you might be able to experiment and teach us how to translate some diagnostics, or there may be an opportunity to extend our core infrastructure (e.g. the derives). Don't worry though, you can always skip a diagnostic and leave it for someone else too.
Where to get help?
Discussion is primarily happening in the
#i18nstream on Zulip. Ask any questions you have in that chat and someone will try to help. If you don't get a response, feel free to ping@davidtwcoor@t-compiler/wg-diagnostics.One-off tasks
Sometimes there are one-off tasks which improve compiler infrastructure around translation or just make things easier to use, these are listed below, feel free to comment to take them:
Completed
Extendmacros: diagnostic derive on enums #102189SessionDiagnosticderive to work on enums (context)In #100753, there are some functions annotated withlint: avoid linting diag functions with diag lints #101230#[rustc_lint_diagnostics]which is used to know when to trigger our internal lints, that are themselves triggering the internal lint - it would be good to change the internal lint so that it skips functions annotated with#[rustc_lint_diagnostics].SupportDiagnostic derives: allow specifying multiple alternative suggestions #103209span_suggestions-equivalent in diagnostic derives.errors: generate typed identifiers in each crate #103042Diagnosticsicu4xbased list formatting. #104047In-progress
To-do
DefIdtoSpanconversions in the derive macros, e.g.#[primary_span(def_span)]or something like that (context).Option<impl IntoDiagnosticArg>(context)MultiSpan(context).IntoDiagnosticSpantrait that can be implemented for anything usable with#[primary_span](i.e. so we can extend#[primary_span]support toIdenteasily, for example) (partially complete at https://github.com/davidtwco/rust/tree/translation-into-diagnostic-span)