mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
rustc_errors: remove struct_dummy
.
This commit is contained in:
parent
d4fc5ae25c
commit
8562d6b752
@ -622,14 +622,6 @@ impl Handler {
|
||||
self.inner.borrow_mut().emit_stashed_diagnostics();
|
||||
}
|
||||
|
||||
/// Construct a dummy builder with `Level::Cancelled`.
|
||||
///
|
||||
/// Using this will neither report anything to the user (e.g. a warning),
|
||||
/// nor will compilation cancel as a result.
|
||||
pub fn struct_dummy(&self) -> DiagnosticBuilder<'_> {
|
||||
DiagnosticBuilder::new(self, Level::Cancelled, "")
|
||||
}
|
||||
|
||||
/// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
|
||||
///
|
||||
/// Attempting to `.emit()` the builder will only emit if either:
|
||||
|
@ -1482,12 +1482,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
let actual_ty = self.resolve_vars_if_possible(actual_ty);
|
||||
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
|
||||
|
||||
let mut err = mk_diag(self.ty_to_string(actual_ty));
|
||||
|
||||
// Don't report an error if actual type is `Error`.
|
||||
if actual_ty.references_error() {
|
||||
return self.tcx.sess.diagnostic().struct_dummy();
|
||||
err.downgrade_to_delayed_bug();
|
||||
}
|
||||
|
||||
mk_diag(self.ty_to_string(actual_ty))
|
||||
err
|
||||
}
|
||||
|
||||
pub fn report_mismatched_types(
|
||||
|
@ -1622,9 +1622,11 @@ impl<'a> Parser<'a> {
|
||||
};
|
||||
if let Some(expr) = expr {
|
||||
if matches!(expr.kind, ExprKind::Err) {
|
||||
self.diagnostic()
|
||||
.delay_span_bug(self.token.span, &"invalid interpolated expression");
|
||||
return self.diagnostic().struct_dummy();
|
||||
let mut err = self
|
||||
.diagnostic()
|
||||
.struct_span_err(self.token.span, &"invalid interpolated expression");
|
||||
err.downgrade_to_delayed_bug();
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user