Map our diagnostics to rustc and clippy's ones

This commit is contained in:
hkalbasi 2023-06-15 01:47:22 +03:30
parent 9c967d3809
commit e55a1f1916
44 changed files with 628 additions and 251 deletions

View file

@ -1,17 +1,17 @@
use hir::InFile;
use crate::{Diagnostic, DiagnosticsContext, Severity};
use crate::{Diagnostic, DiagnosticCode, DiagnosticsContext};
// Diagnostic: incoherent-impl
//
// This diagnostic is triggered if the targe type of an impl is from a foreign crate.
pub(crate) fn incoherent_impl(ctx: &DiagnosticsContext<'_>, d: &hir::IncoherentImpl) -> Diagnostic {
Diagnostic::new(
"incoherent-impl",
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::RustcHardError("E0210"),
format!("cannot define inherent `impl` for foreign type"),
ctx.sema.diagnostics_display_range(InFile::new(d.file_id, d.impl_.clone().into())).range,
InFile::new(d.file_id, d.impl_.clone().into()),
)
.severity(Severity::Error)
}
#[cfg(test)]