-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
More translatable diagnostics #123822
Changes from 1 commit
78fba85
1a09dd4
3ae0ae9
da547b7
0a7d3da
bbb3759
7ff2696
332ebed
9d9ad48
bce7c46
e7c1fd3
bd98f08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use rustc_errors::codes::*; | ||
use rustc_errors::{Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic}; | ||
use rustc_macros::{Diagnostic, Subdiagnostic}; | ||
use rustc_session::errors::FeatureGateSubdiagnostic; | ||
use rustc_span::symbol::Ident; | ||
use rustc_span::{Span, Symbol}; | ||
|
||
|
@@ -386,12 +387,16 @@ pub(crate) enum BadReturnTypeNotation { | |
#[primary_span] | ||
#[suggestion(code = "()", applicability = "maybe-incorrect")] | ||
span: Span, | ||
#[subdiagnostic] | ||
subdiag: Option<FeatureGateSubdiagnostic>, | ||
}, | ||
#[diag(ast_lowering_bad_return_type_notation_output)] | ||
Output { | ||
#[primary_span] | ||
#[suggestion(code = "", applicability = "maybe-incorrect")] | ||
span: Span, | ||
#[subdiagnostic] | ||
subdiag: Option<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? |
||
}, | ||
#[diag(ast_lowering_bad_return_type_notation_needs_dots)] | ||
NeedsDots { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ use rustc_index::{Idx, IndexSlice, IndexVec}; | |
use rustc_macros::extension; | ||
use rustc_middle::span_bug; | ||
use rustc_middle::ty::{ResolverAstLowering, TyCtxt}; | ||
use rustc_session::parse::{add_feature_diagnostics, feature_err}; | ||
use rustc_session::parse::{feature_err, get_feature_diagnostics}; | ||
use rustc_span::symbol::{kw, sym, Ident, Symbol}; | ||
use rustc_span::{DesugaringKind, Span, DUMMY_SP}; | ||
use smallvec::{smallvec, SmallVec}; | ||
|
@@ -1008,29 +1008,29 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { | |
if let Some(first_char) = constraint.ident.as_str().chars().next() | ||
&& first_char.is_ascii_lowercase() | ||
{ | ||
let mut err = if !data.inputs.is_empty() { | ||
self.dcx().create_err(errors::BadReturnTypeNotation::Inputs { | ||
let subdiag = if !self.tcx.features().return_type_notation | ||
&& self.tcx.sess.is_nightly_build() | ||
{ | ||
Some(get_feature_diagnostics(&self.tcx.sess, sym::return_type_notation)) | ||
} else { | ||
None | ||
}; | ||
|
||
let err = if !data.inputs.is_empty() { | ||
errors::BadReturnTypeNotation::Inputs { | ||
span: data.inputs_span, | ||
}) | ||
subdiag, | ||
} | ||
} else if let FnRetTy::Ty(ty) = &data.output { | ||
self.dcx().create_err(errors::BadReturnTypeNotation::Output { | ||
errors::BadReturnTypeNotation::Output { | ||
span: data.inputs_span.shrink_to_hi().to(ty.span), | ||
}) | ||
subdiag, | ||
} | ||
} else { | ||
self.dcx().create_err(errors::BadReturnTypeNotation::NeedsDots { | ||
span: data.inputs_span, | ||
}) | ||
errors::BadReturnTypeNotation::NeedsDots { span: data.inputs_span } | ||
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. No subdiagnostic for this one? |
||
}; | ||
if !self.tcx.features().return_type_notation | ||
&& self.tcx.sess.is_nightly_build() | ||
{ | ||
add_feature_diagnostics( | ||
&mut err, | ||
&self.tcx.sess, | ||
sym::return_type_notation, | ||
); | ||
} | ||
err.emit(); | ||
self.dcx().create_err(err).emit(); | ||
|
||
GenericArgsCtor { | ||
args: Default::default(), | ||
constraints: &[], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ use rustc_errors::{ | |
}; | ||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; | ||
use rustc_middle::ty::Ty; | ||
use rustc_session::errors::FeatureGateSubdiagnostic; | ||
use rustc_span::symbol::Ident; | ||
use rustc_span::{Span, Symbol}; | ||
|
||
|
@@ -987,6 +988,8 @@ pub(crate) struct MissingTraitItemUnstable { | |
pub some_note: bool, | ||
#[note(hir_analysis_none_note)] | ||
pub none_note: bool, | ||
#[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? |
||
pub missing_item_name: Symbol, | ||
pub feature: Symbol, | ||
pub reason: String, | ||
|
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?