diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-14 10:35:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-14 10:35:31 +0200 |
| commit | d8333a7b59c7b1308955bbd5a37ceabf86ec7dea (patch) | |
| tree | 6427dd859358312a704cb5d46591c259360da9e5 /compiler/rustc_session/src | |
| parent | 9e5c5c57e97098b4d1e04a1215628ff6eb54986b (diff) | |
| parent | 5ba81faba632883ee69be0d216959a5ef3bba030 (diff) | |
| download | rust-d8333a7b59c7b1308955bbd5a37ceabf86ec7dea.tar.gz rust-d8333a7b59c7b1308955bbd5a37ceabf86ec7dea.zip | |
Rollup merge of #97948 - davidtwco:diagnostic-translation-lints, r=oli-obk
lint: add diagnostic translation migration lints Introduce allow-by-default lints for checking whether diagnostics are written in `SessionDiagnostic` or `AddSubdiagnostic` impls and whether diagnostics are translatable. These lints can be denied for modules once they are fully migrated to impls and translation. These lints are intended to be temporary - once all diagnostics have been changed then we can just change the APIs we have and that will enforce these constraints thereafter. r? `````@oli-obk`````
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 1 |
3 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 59b4981dd01..044be906b55 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -5,6 +5,7 @@ #![feature(never_type)] #![feature(once_cell)] #![feature(option_get_or_insert_default)] +#![feature(rustc_attrs)] #![recursion_limit = "256"] #![allow(rustc::potential_query_instability)] diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 6fb87e15a33..a5ccae047fc 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -311,6 +311,7 @@ impl ParseSess { self.create_warning(warning).emit() } + #[cfg_attr(not(bootstrap), rustc_lint_diagnostics)] pub fn struct_err( &self, msg: impl Into<DiagnosticMessage>, @@ -318,6 +319,7 @@ impl ParseSess { self.span_diagnostic.struct_err(msg) } + #[cfg_attr(not(bootstrap), rustc_lint_diagnostics)] pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> { self.span_diagnostic.struct_warn(msg) } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index b2c23cda6aa..b1d1f9e7a6c 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -209,6 +209,7 @@ pub struct PerfStats { /// Trait implemented by error types. This should not be implemented manually. Instead, use /// `#[derive(SessionDiagnostic)]` -- see [rustc_macros::SessionDiagnostic]. +#[rustc_diagnostic_item = "SessionDiagnostic"] pub trait SessionDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> { /// Write out as a diagnostic out of `sess`. #[must_use] |
