Skip to content

Commit be4059d

Browse files
committed
migrate stability.rs to translateable diagnostics
1 parent 3fe8e00 commit be4059d

File tree

3 files changed

+209
-84
lines changed

3 files changed

+209
-84
lines changed

compiler/rustc_error_messages/locales/en-US/passes.ftl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,53 @@ passes_attribute_should_be_applied_to =
600600
601601
passes_transparent_incompatible =
602602
transparent {$target} cannot have other repr hints
603+
604+
passes_deprecated_attribute =
605+
deprecated attribute must be paired with either stable or unstable attribute
606+
607+
passes_useless_stability =
608+
this stability annotation is useless
609+
.label = useless stability annotation
610+
.item = the stability attribute annotates this item
611+
612+
passes_invalid_stability =
613+
invalid stability version found
614+
.label = invalid stability version
615+
.item = the stability attribute annotates this item
616+
617+
passes_cannot_stabilize_deprecated =
618+
an API can't be stabilized after it is deprecated
619+
.label = invalid version
620+
.item = the stability attribute annotates this item
621+
622+
passes_invalid_deprecation_version =
623+
invalid deprecation version found
624+
.label = invalid deprecation version
625+
.item = the stability attribute annotates this item
626+
627+
passes_missing_stability_attr =
628+
{$descr} has missing stability attribute
629+
630+
passes_missing_const_stab_attr =
631+
{$descr} has missing const stability attribute
632+
633+
passes_trait_impl_const_stable =
634+
trait implementations cannot be const stable yet
635+
.note = see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
636+
637+
passes_feature_only_on_nightly =
638+
`#![feature]` may not be used on the {$release_channel} release channel
639+
640+
passes_unknown_feature =
641+
unknown feature `{$feature}`
642+
643+
passes_implied_feature_not_exist =
644+
feature `{$implied_by}` implying `{$feature}` does not exist
645+
646+
passes_duplicate_feature_err =
647+
the feature `{$feature}` has already been declared
648+
649+
passes_missing_const_err =
650+
attributes `#[rustc_const_unstable]` and `#[rustc_const_stable]` require the function or method to be `const`
651+
.help = make the function or method const
652+
.label = attribute specified here

compiler/rustc_passes/src/errors.rs

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,3 +1313,116 @@ pub struct TransparentIncompatible {
13131313
pub hint_spans: Vec<Span>,
13141314
pub target: String,
13151315
}
1316+
1317+
#[derive(Diagnostic)]
1318+
#[diag(passes::deprecated_attribute, code = "E0549")]
1319+
pub struct DeprecatedAttribute {
1320+
#[primary_span]
1321+
pub span: Span,
1322+
}
1323+
1324+
#[derive(Diagnostic)]
1325+
#[diag(passes::useless_stability)]
1326+
pub struct UselessStability {
1327+
#[primary_span]
1328+
#[label]
1329+
pub span: Span,
1330+
#[label(passes::item)]
1331+
pub item_sp: Span,
1332+
}
1333+
1334+
#[derive(Diagnostic)]
1335+
#[diag(passes::invalid_stability)]
1336+
pub struct InvalidStability {
1337+
#[primary_span]
1338+
#[label]
1339+
pub span: Span,
1340+
#[label(passes::item)]
1341+
pub item_sp: Span,
1342+
}
1343+
1344+
#[derive(Diagnostic)]
1345+
#[diag(passes::cannot_stabilize_deprecated)]
1346+
pub struct CannotStabilizeDeprecated {
1347+
#[primary_span]
1348+
#[label]
1349+
pub span: Span,
1350+
#[label(passes::item)]
1351+
pub item_sp: Span,
1352+
}
1353+
1354+
#[derive(Diagnostic)]
1355+
#[diag(passes::invalid_deprecation_version)]
1356+
pub struct InvalidDeprecationVersion {
1357+
#[primary_span]
1358+
#[label]
1359+
pub span: Span,
1360+
#[label(passes::item)]
1361+
pub item_sp: Span,
1362+
}
1363+
1364+
#[derive(Diagnostic)]
1365+
#[diag(passes::missing_stability_attr)]
1366+
pub struct MissingStabilityAttr<'a> {
1367+
#[primary_span]
1368+
pub span: Span,
1369+
pub descr: &'a str,
1370+
}
1371+
1372+
#[derive(Diagnostic)]
1373+
#[diag(passes::missing_const_stab_attr)]
1374+
pub struct MissingConstStabAttr<'a> {
1375+
#[primary_span]
1376+
pub span: Span,
1377+
pub descr: &'a str,
1378+
}
1379+
1380+
#[derive(Diagnostic)]
1381+
#[diag(passes::trait_impl_const_stable)]
1382+
#[note]
1383+
pub struct TraitImplConstStable {
1384+
#[primary_span]
1385+
pub span: Span,
1386+
}
1387+
1388+
#[derive(Diagnostic)]
1389+
#[diag(passes::feature_only_on_nightly, code = "E0554")]
1390+
pub struct FeatureOnlyOnNightly {
1391+
#[primary_span]
1392+
pub span: Span,
1393+
pub release_channel: &'static str,
1394+
}
1395+
1396+
#[derive(Diagnostic)]
1397+
#[diag(passes::unknown_feature, code = "E0635")]
1398+
pub struct UnknownFeature {
1399+
#[primary_span]
1400+
pub span: Span,
1401+
pub feature: Symbol,
1402+
}
1403+
1404+
#[derive(Diagnostic)]
1405+
#[diag(passes::implied_feature_not_exist)]
1406+
pub struct ImpliedFeatureNotExist {
1407+
#[primary_span]
1408+
pub span: Span,
1409+
pub feature: Symbol,
1410+
pub implied_by: Symbol,
1411+
}
1412+
1413+
#[derive(Diagnostic)]
1414+
#[diag(passes::duplicate_feature_err, code = "E0636")]
1415+
pub struct DuplicateFeatureErr {
1416+
#[primary_span]
1417+
pub span: Span,
1418+
pub feature: Symbol,
1419+
}
1420+
#[derive(Diagnostic)]
1421+
#[diag(passes::missing_const_err)]
1422+
pub struct MissingConstErr {
1423+
#[primary_span]
1424+
#[help]
1425+
pub fn_sig_span: Span,
1426+
#[label]
1427+
pub const_span: Span,
1428+
}

0 commit comments

Comments
 (0)