1
Fork 0

rustc_errors: remove struct_dummy.

This commit is contained in:
Eduard-Mihai Burtescu 2022-01-26 04:40:43 +00:00
parent d4fc5ae25c
commit 8562d6b752
7 changed files with 41 additions and 38 deletions

View file

@ -268,7 +268,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(None, true) => "variant",
}
};
let mut err = if !actual.references_error() {
// FIXME(eddyb) this intendation is probably unnecessary.
let mut err = {
// Suggest clamping down the type if the method that is being attempted to
// be used exists at all, and the type is an ambiguous numeric type
// ({integer}/{float}).
@ -461,10 +462,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
err
}
} else {
tcx.sess.diagnostic().struct_dummy()
};
if actual.references_error() {
err.downgrade_to_delayed_bug();
}
if let Some(def) = actual.ty_adt_def() {
if let Some(full_sp) = tcx.hir().span_if_local(def.did) {
let def_sp = tcx.sess.source_map().guess_head_span(full_sp);

View file

@ -139,11 +139,13 @@ pub use self::Expectation::*;
#[macro_export]
macro_rules! type_error_struct {
($session:expr, $span:expr, $typ:expr, $code:ident, $($message:tt)*) => ({
let mut err = rustc_errors::struct_span_err!($session, $span, $code, $($message)*);
if $typ.references_error() {
$session.diagnostic().struct_dummy()
} else {
rustc_errors::struct_span_err!($session, $span, $code, $($message)*)
err.downgrade_to_delayed_bug();
}
err
})
}

View file

@ -21,15 +21,15 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx> {
}
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(),
)
};
let mut err = self.sess.struct_span_fatal_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(

View file

@ -21,18 +21,20 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCast<'tcx> {
}
fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx> {
let mut err = self.sess.struct_span_fatal_with_code(
self.span,
&format!(
"cannot cast thin pointer `{}` to fat pointer `{}`",
self.expr_ty, self.cast_ty
),
self.code(),
);
if self.expr_ty.references_error() {
self.sess.diagnostic().struct_dummy()
} else {
self.sess.struct_span_fatal_with_code(
self.span,
&format!(
"cannot cast thin pointer `{}` to fat pointer `{}`",
self.expr_ty, self.cast_ty
),
self.code(),
)
err.downgrade_to_delayed_bug();
}
err
}
fn diagnostic_extended(&self, mut err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> {