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`````
This commit is contained in:
commit
d8333a7b59
15 changed files with 327 additions and 37 deletions
|
@ -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)]
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue