about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/structured_errors.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-17 07:33:52 +0000
committerbors <bors@rust-lang.org>2024-01-17 07:33:52 +0000
commit16f4b02dd8a2e16b8fb0a236399088e2cf301e63 (patch)
treec1a6de497f7615716efeeefdd6f79215419f3fc8 /compiler/rustc_hir_analysis/src/structured_errors.rs
parentf45fe573a587f5d82e9e78cbece64bad4b3709f8 (diff)
parentd71f535a6f39e82313b46ac3157c4ed9267a2e40 (diff)
downloadrust-16f4b02dd8a2e16b8fb0a236399088e2cf301e63.tar.gz
rust-16f4b02dd8a2e16b8fb0a236399088e2cf301e63.zip
Auto merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obk
Rework how diagnostic lints are stored.

`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and
`Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be
redundant w.r.t. `Diagnostic::code`.

Seems simple. Except it's possible for a lint to have an error code, in
which case its `code` field is recorded as `Error`, and `is_lint` is
required to indicate that it's a lint. This is what happens with
`derive(LintDiagnostic)` lints. Which means those lints don't have a
lint name or a `has_future_breakage` field because those are stored in
the `DiagnosticId::Lint`.

It's all a bit messy and confused and seems unintentional.

This commit:
- removes `DiagnosticId`;
- changes `Diagnostic::code` to `Option<String>`, which means both
  errors and lints can straightforwardly have an error code;
- changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a
  new type containing a lint name and a `has_future_breakage` bool, so
  all lints can have those, error code or not.

r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_hir_analysis/src/structured_errors.rs')
-rw-r--r--compiler/rustc_hir_analysis/src/structured_errors.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/structured_errors.rs b/compiler/rustc_hir_analysis/src/structured_errors.rs
index 04d04304e70..b061d637138 100644
--- a/compiler/rustc_hir_analysis/src/structured_errors.rs
+++ b/compiler/rustc_hir_analysis/src/structured_errors.rs
@@ -6,13 +6,13 @@ pub use self::{
     missing_cast_for_variadic_arg::*, sized_unsized_cast::*, wrong_number_of_generic_args::*,
 };
 
-use rustc_errors::{DiagnosticBuilder, DiagnosticId};
+use rustc_errors::DiagnosticBuilder;
 use rustc_session::Session;
 
 pub trait StructuredDiagnostic<'tcx> {
     fn session(&self) -> &Session;
 
-    fn code(&self) -> DiagnosticId;
+    fn code(&self) -> String;
 
     fn diagnostic(&self) -> DiagnosticBuilder<'tcx> {
         let err = self.diagnostic_common();