summary refs log tree commit diff
path: root/compiler/rustc_error_messages/src
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-06-10 15:50:06 +0100
committerDavid Wood <david.wood@huawei.com>2022-06-10 15:50:06 +0100
commit5ba81faba632883ee69be0d216959a5ef3bba030 (patch)
tree8d0940ffb1e0dc97e79a692625e16e617a8ff555 /compiler/rustc_error_messages/src
parent52ee2a2738c957ca6fd54e97b4e090a266ba96ba (diff)
downloadrust-5ba81faba632883ee69be0d216959a5ef3bba030.tar.gz
rust-5ba81faba632883ee69be0d216959a5ef3bba030.zip
lint: add diagnostic translation migration lints
Introduce allow-by-default lints for checking whether diagnostics are
written in `SessionDiagnostic`/`AddSubdiagnostic` impls and whether
diagnostics are translatable. These lints can be denied for modules once
they are fully migrated to impls and translation.

Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_error_messages/src')
-rw-r--r--compiler/rustc_error_messages/src/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs
index 02d076c95ca..fd4b2daae9c 100644
--- a/compiler/rustc_error_messages/src/lib.rs
+++ b/compiler/rustc_error_messages/src/lib.rs
@@ -1,6 +1,7 @@
 #![feature(let_chains)]
 #![feature(once_cell)]
 #![feature(path_try_exists)]
+#![feature(rustc_attrs)]
 #![feature(type_alias_impl_trait)]
 
 use fluent_bundle::FluentResource;
@@ -241,6 +242,7 @@ type FluentId = Cow<'static, str>;
 /// message so messages of this type must be combined with a `DiagnosticMessage` (using
 /// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from
 /// the `SessionSubdiagnostic` derive refer to Fluent identifiers directly.
+#[rustc_diagnostic_item = "SubdiagnosticMessage"]
 pub enum SubdiagnosticMessage {
     /// Non-translatable diagnostic message.
     // FIXME(davidtwco): can a `Cow<'static, str>` be used here?
@@ -281,6 +283,7 @@ impl<S: Into<String>> From<S> for SubdiagnosticMessage {
 ///
 /// Intended to be removed once diagnostics are entirely translatable.
 #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
+#[rustc_diagnostic_item = "DiagnosticMessage"]
 pub enum DiagnosticMessage {
     /// Non-translatable diagnostic message.
     // FIXME(davidtwco): can a `Cow<'static, str>` be used here?