use crate::structured_errors::StructuredDiagnostic;
-use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId};
+use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
use rustc_middle::ty::{Ty, TypeFoldable};
use rustc_session::Session;
use rustc_span::Span;
rustc_errors::error_code!(E0617)
}
- fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx> {
- let mut err = if self.ty.references_error() {
- self.sess.diagnostic().struct_dummy()
- } else {
- self.sess.struct_span_fatal_with_code(
- self.span,
- &format!("can't pass `{}` to variadic function", self.ty),
- self.code(),
- )
- };
+ fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
+ let mut err = self.sess.struct_span_err_with_code(
+ self.span,
+ &format!("can't pass `{}` to variadic function", self.ty),
+ self.code(),
+ );
+
+ if self.ty.references_error() {
+ err.downgrade_to_delayed_bug();
+ }
if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.span) {
err.span_suggestion(
err
}
- fn diagnostic_extended(&self, mut err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> {
+ fn diagnostic_extended(
+ &self,
+ mut err: DiagnosticBuilder<'tcx, ErrorGuaranteed>,
+ ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
err.note(&format!(
"certain types, like `{}`, must be casted before passing them to a \
variadic function, because of arcane ABI rules dictated by the C \