-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
More translatable diagnostics #123822
Closed
Closed
More translatable diagnostics #123822
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
78fba85
Fix diagnostics to invalid metavar exprs
Xiretza 1a09dd4
Fix typo in meta-var expr diagnostics
Xiretza 3ae0ae9
rustc_expand: add FIXMEs for translation
Xiretza da547b7
Factor out ICU4X list formatter creation
Xiretza 0a7d3da
rustc_baked_icu_data: regenerate
Xiretza bbb3759
Add StrListSepByOr
Xiretza 7ff2696
rustc_session: turn feature gate subdiagnostic into struct
Xiretza 332ebed
Expose FeatureGateSubdiagnostic struct instead of applying it opaquely
Xiretza 9d9ad48
impl IntoDiagArg for TokenTree
Xiretza bce7c46
impl IntoDiagArg for NonterminalKind
Xiretza e7c1fd3
Make more diagnostics in rustc_expand translatable
Xiretza bd98f08
rustc_expand: make mbe translatable
Xiretza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ use std::borrow::Cow; | |
|
||
use rustc_ast::ast; | ||
use rustc_errors::codes::*; | ||
use rustc_errors::IntoDiagArg; | ||
use rustc_macros::{Diagnostic, Subdiagnostic}; | ||
use rustc_session::errors::FeatureGateSubdiagnostic; | ||
use rustc_session::Limit; | ||
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; | ||
use rustc_span::{Span, Symbol}; | ||
|
@@ -485,3 +487,38 @@ pub(crate) struct ProcMacroBackCompat { | |
pub crate_name: String, | ||
pub fixed_version: String, | ||
} | ||
|
||
pub(crate) enum StatementOrExpression { | ||
Statement, | ||
Expression, | ||
} | ||
|
||
impl IntoDiagArg for StatementOrExpression { | ||
fn into_diag_arg(self) -> rustc_errors::DiagArgValue { | ||
let s = match self { | ||
StatementOrExpression::Statement => "statement", | ||
StatementOrExpression::Expression => "expression", | ||
}; | ||
|
||
rustc_errors::DiagArgValue::Str(s.into()) | ||
} | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(expand_custom_attribute_cannot_be_applied, code = E0658)] | ||
pub(crate) struct CustomAttributesForbidden { | ||
#[primary_span] | ||
pub span: Span, | ||
#[subdiagnostic] | ||
pub subdiag: FeatureGateSubdiagnostic, | ||
pub kind: StatementOrExpression, | ||
} | ||
|
||
#[derive(Diagnostic)] | ||
#[diag(expand_non_inline_modules_in_proc_macro_input_are_unstable, code = E0658)] | ||
pub(crate) struct NonInlineModuleInProcMacroUnstable { | ||
#[primary_span] | ||
pub span: Span, | ||
#[subdiagnostic] | ||
pub subdiag: FeatureGateSubdiagnostic, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use a more descriptive name? |
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use a more descriptive name?