-
Notifications
You must be signed in to change notification settings - Fork 13k
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 all commits
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 |
---|---|---|
|
@@ -14,33 +14,39 @@ | |
#[macro_export] | ||
macro_rules! __make_provider { | ||
($ name : ty) => { | ||
#[clippy::msrv = "1.66"] | ||
#[clippy::msrv = "1.67"] | ||
impl $name { | ||
#[doc(hidden)] | ||
#[allow(dead_code)] | ||
pub const MUST_USE_MAKE_PROVIDER_MACRO: () = (); | ||
} | ||
icu_provider::impl_data_provider_never_marker!($name); | ||
}; | ||
} | ||
#[doc(inline)] | ||
pub use __make_provider as make_provider; | ||
#[macro_use] | ||
#[path = "macros/fallback_likelysubtags_v1.data.rs"] | ||
#[path = "macros/fallback_likelysubtags_v1.rs.data"] | ||
mod fallback_likelysubtags_v1; | ||
#[doc(inline)] | ||
pub use __impl_fallback_likelysubtags_v1 as impl_fallback_likelysubtags_v1; | ||
#[macro_use] | ||
#[path = "macros/fallback_parents_v1.data.rs"] | ||
#[path = "macros/fallback_parents_v1.rs.data"] | ||
mod fallback_parents_v1; | ||
#[doc(inline)] | ||
pub use __impl_fallback_parents_v1 as impl_fallback_parents_v1; | ||
#[macro_use] | ||
#[path = "macros/fallback_supplement_co_v1.data.rs"] | ||
#[path = "macros/fallback_supplement_co_v1.rs.data"] | ||
mod fallback_supplement_co_v1; | ||
#[doc(inline)] | ||
pub use __impl_fallback_supplement_co_v1 as impl_fallback_supplement_co_v1; | ||
#[macro_use] | ||
#[path = "macros/list_and_v1.data.rs"] | ||
#[path = "macros/list_and_v1.rs.data"] | ||
mod list_and_v1; | ||
#[doc(inline)] | ||
pub use __impl_list_and_v1 as impl_list_and_v1; | ||
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. I don't understand this sentence in the commit message:
Could an |
||
#[macro_use] | ||
#[path = "macros/list_or_v1.rs.data"] | ||
mod list_or_v1; | ||
#[doc(inline)] | ||
pub use __impl_list_or_v1 as impl_list_or_v1; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// @generated | ||
/// Implement `DataProvider<LocaleFallbackLikelySubtagsV1Marker>` on the given struct using the data | ||
/// hardcoded in this file. This allows the struct to be used with | ||
/// `icu`'s `_unstable` constructors. | ||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __impl_fallback_likelysubtags_v1 { | ||
($ provider : ty) => { | ||
#[clippy::msrv = "1.67"] | ||
const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; | ||
#[clippy::msrv = "1.67"] | ||
impl $provider { | ||
#[doc(hidden)] | ||
pub const SINGLETON_FALLBACK_LIKELYSUBTAGS_V1: &'static <icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker as icu_provider::DataMarker>::Yokeable = &icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1 { | ||
l2s: unsafe { | ||
#[allow(unused_unsafe)] | ||
zerovec::ZeroMap::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"am\0ar\0as\0be\0bg\0bgcbhobn\0brxchrcswcv\0doiel\0fa\0gu\0he\0hi\0hy\0ja\0ka\0kk\0km\0kn\0ko\0kokks\0ky\0lo\0maimk\0ml\0mn\0mnimr\0my\0ne\0nqoor\0pa\0ps\0rajru\0sa\0sahsatsd\0si\0sr\0syrta\0te\0tg\0th\0ti\0tt\0ug\0uk\0ur\0xnryuezh\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"EthiArabBengCyrlCyrlDevaDevaBengDevaCherCansCyrlDevaGrekArabGujrHebrDevaArmnJpanGeorCyrlKhmrKndaKoreDevaArabCyrlLaooDevaCyrlMlymCyrlBengDevaMymrDevaNkooOryaGuruArabDevaCyrlDevaCyrlOlckArabSinhCyrlSyrcTamlTeluCyrlThaiEthiCyrlArabCyrlArabDevaHantHans") }) | ||
}, | ||
lr2s: unsafe { | ||
#[allow(unused_unsafe)] | ||
zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"az\0ha\0kk\0ku\0ky\0mn\0ms\0pa\0sd\0sr\0tg\0ug\0uz\0yuezh\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x03\0\0\0\x05\0\0\0\t\0\0\0\n\0\0\0\x0C\0\0\0\r\0\0\0\x0E\0\0\0\x0F\0\0\0\x10\0\0\0\x14\0\0\0\x15\0\0\0\x17\0\0\0\x19\0\0\0\x1A\0\0\0)\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"IQ\0IR\0RU\0CM\0SD\0AF\0CN\0IR\0MN\0LB\0CN\0TR\0CN\0CC\0PK\0IN\0ME\0RO\0RU\0TR\0PK\0KZ\0MN\0AF\0CN\0CN\0AU\0BN\0GB\0GF\0HK\0ID\0MO\0PA\0PF\0PH\0SR\0TH\0TW\0US\0VN\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"ArabArabCyrlArabArabArabArabArabArabArabArabLatnMongArabArabDevaLatnLatnLatnLatnArabCyrlCyrlArabCyrlHansHantHantHantHantHantHantHantHantHantHantHantHantHantHantHant") }) | ||
}, | ||
l2r: unsafe { | ||
#[allow(unused_unsafe)] | ||
zerovec::ZeroMap::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"af\0am\0ar\0as\0astaz\0be\0bg\0bgcbhoblobn\0br\0brxbs\0ca\0cebchrcs\0cswcv\0cy\0da\0de\0doidsbel\0en\0eo\0es\0et\0eu\0fa\0ff\0fi\0filfo\0fr\0fy\0ga\0gd\0gl\0gu\0ha\0he\0hi\0hr\0hsbhu\0hy\0ia\0id\0ie\0ig\0is\0it\0ja\0jv\0ka\0keakgpkk\0km\0kn\0ko\0kokks\0ku\0kxvky\0lb\0lijlmolo\0lt\0lv\0maimi\0mk\0ml\0mn\0mnimr\0ms\0mt\0my\0ndsne\0nl\0nn\0no\0nqooc\0or\0pa\0pcmpl\0prgps\0pt\0qu\0rajrm\0ro\0ru\0sa\0sahsatsc\0sd\0si\0sk\0sl\0so\0sq\0sr\0su\0sv\0sw\0syrszlta\0te\0tg\0th\0ti\0tk\0to\0tr\0tt\0ug\0uk\0ur\0uz\0vecvi\0vmwwo\0xh\0xnryo\0yrlyueza\0zh\0zu\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"ZA\0ET\0EG\0IN\0ES\0AZ\0BY\0BG\0IN\0IN\0BJ\0BD\0FR\0IN\0BA\0ES\0PH\0US\0CZ\0CA\0RU\0GB\0DK\0DE\0IN\0DE\0GR\0US\x00001ES\0EE\0ES\0IR\0SN\0FI\0PH\0FO\0FR\0NL\0IE\0GB\0ES\0IN\0NG\0IL\0IN\0HR\0DE\0HU\0AM\x00001ID\0EE\0NG\0IS\0IT\0JP\0ID\0GE\0CV\0BR\0KZ\0KH\0IN\0KR\0IN\0IN\0TR\0IN\0KG\0LU\0IT\0IT\0LA\0LT\0LV\0IN\0NZ\0MK\0IN\0MN\0IN\0IN\0MY\0MT\0MM\0DE\0NP\0NL\0NO\0NO\0GN\0FR\0IN\0IN\0NG\0PL\0PL\0AF\0BR\0PE\0IN\0CH\0RO\0RU\0IN\0RU\0IN\0IT\0PK\0LK\0SK\0SI\0SO\0AL\0RS\0ID\0SE\0TZ\0IQ\0PL\0IN\0IN\0TJ\0TH\0ET\0TM\0TO\0TR\0RU\0CN\0UA\0PK\0UZ\0IT\0VN\0MZ\0SN\0ZA\0IN\0NG\0BR\0HK\0CN\0CN\0ZA\0") }) | ||
}, | ||
ls2r: unsafe { | ||
#[allow(unused_unsafe)] | ||
zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"az\0en\0ff\0kk\0ku\0ky\0mn\0pa\0sd\0tg\0ug\0uz\0yuezh\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x01\0\0\0\x02\0\0\0\x03\0\0\0\x04\0\0\0\x06\0\0\0\x08\0\0\0\t\0\0\0\n\0\0\0\r\0\0\0\x0E\0\0\0\x0F\0\0\0\x10\0\0\0\x11\0\0\0\x14\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"ArabShawAdlmArabArabYeziArabLatnMongArabDevaKhojSindArabCyrlArabHansBopoHanbHant") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"IR\0GB\0GN\0CN\0IQ\0GE\0CN\0TR\0CN\0PK\0IN\0IN\0IN\0PK\0KZ\0AF\0CN\0TW\0TW\0TW\0") }) | ||
}, | ||
}; | ||
} | ||
#[clippy::msrv = "1.67"] | ||
impl icu_provider::DataProvider<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker> for $provider { | ||
fn load(&self, req: icu_provider::DataRequest) -> Result<icu_provider::DataResponse<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker>, icu_provider::DataError> { | ||
if req.locale.is_empty() { Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_FALLBACK_LIKELYSUBTAGS_V1)), metadata: Default::default() }) } else { Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker as icu_provider::KeyedDataMarker>::KEY, req)) } | ||
} | ||
} | ||
}; | ||
} | ||
/// Implement `IterableDataProvider<LocaleFallbackLikelySubtagsV1Marker>` on the given struct using the data | ||
/// hardcoded in this file. This allows the struct to be used with | ||
/// `DatagenDriver` for this key. | ||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __impliterable_fallback_likelysubtags_v1 { | ||
($ provider : ty) => { | ||
#[clippy::msrv = "1.67"] | ||
impl icu_provider::datagen::IterableDataProvider<icu_locid_transform::provider::LocaleFallbackLikelySubtagsV1Marker> for $provider { | ||
fn supported_locales(&self) -> Result<alloc::vec::Vec<icu_provider::DataLocale>, icu_provider::DataError> { | ||
Ok([icu_provider::DataLocale::default()].into()) | ||
} | ||
} | ||
}; | ||
} |
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?