mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
Add DiagCtxt::delayed_bug
.
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
This commit is contained in:
parent
3c4f1d85af
commit
2ea7a37e11
@ -27,7 +27,7 @@ use rustc_middle::ty::TypeVisitor;
|
||||
use rustc_middle::ty::{self, RegionVid, Ty};
|
||||
use rustc_middle::ty::{Region, TyCtxt};
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::borrowck_errors;
|
||||
use crate::session_diagnostics::{
|
||||
@ -84,7 +84,7 @@ impl<'tcx> RegionErrors<'tcx> {
|
||||
#[track_caller]
|
||||
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
||||
let val = val.into();
|
||||
self.1.sess.dcx().span_delayed_bug(DUMMY_SP, format!("{val:?}"));
|
||||
self.1.sess.dcx().delayed_bug(format!("{val:?}"));
|
||||
self.0.push(val);
|
||||
}
|
||||
pub fn is_empty(&self) -> bool {
|
||||
|
@ -391,10 +391,10 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||
if ecx.tcx.is_ctfe_mir_available(def) {
|
||||
Ok(ecx.tcx.mir_for_ctfe(def))
|
||||
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
|
||||
let guar = ecx.tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
"This is likely a const item that is missing from its impl",
|
||||
);
|
||||
let guar = ecx
|
||||
.tcx
|
||||
.dcx()
|
||||
.delayed_bug("This is likely a const item that is missing from its impl");
|
||||
throw_inval!(AlreadyReported(guar.into()));
|
||||
} else {
|
||||
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us,
|
||||
|
@ -865,10 +865,16 @@ impl DiagCtxt {
|
||||
/// For example, it can be used to create an [`ErrorGuaranteed`]
|
||||
/// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
|
||||
/// directly).
|
||||
///
|
||||
/// If no span is available, use [`DUMMY_SP`].
|
||||
///
|
||||
/// [`DUMMY_SP`]: rustc_span::DUMMY_SP
|
||||
#[track_caller]
|
||||
pub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
|
||||
let treat_next_err_as_bug = self.inner.borrow().treat_next_err_as_bug();
|
||||
if treat_next_err_as_bug {
|
||||
self.bug(msg);
|
||||
}
|
||||
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).emit()
|
||||
}
|
||||
|
||||
/// Like `delayed_bug`, but takes an additional span.
|
||||
///
|
||||
/// Note: this function used to be called `delay_span_bug`. It was renamed
|
||||
/// to match similar functions like `span_err`, `span_warn`, etc.
|
||||
@ -882,9 +888,7 @@ impl DiagCtxt {
|
||||
if treat_next_err_as_bug {
|
||||
self.span_bug(sp, msg);
|
||||
}
|
||||
let mut diagnostic = Diagnostic::new(DelayedBug, msg);
|
||||
diagnostic.span(sp);
|
||||
self.emit_diagnostic(diagnostic).unwrap()
|
||||
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).span_mv(sp).emit()
|
||||
}
|
||||
|
||||
// FIXME(eddyb) note the comment inside `impl Drop for DiagCtxtInner`, that's
|
||||
|
@ -659,10 +659,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
||||
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||
} else {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("parent item: {parent_impl:?} not marked as default"),
|
||||
);
|
||||
tcx.dcx().delayed_bug(format!("parent item: {parent_impl:?} not marked as default"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use rustc_middle::ty::{
|
||||
self, GenericArgs, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
|
||||
};
|
||||
use rustc_middle::ty::{GenericParamDefKind, TyCtxt};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
|
||||
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::{
|
||||
@ -942,9 +942,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
||||
.note_mv(format!("hidden type inferred to be `{}`", self.ty))
|
||||
.emit()
|
||||
}
|
||||
_ => {
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
||||
}
|
||||
_ => self.tcx.dcx().delayed_bug("should've been able to remap region"),
|
||||
};
|
||||
return Err(guar);
|
||||
};
|
||||
@ -1303,8 +1301,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
// inheriting the generics from will also have mismatched arguments, and
|
||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||
if trait_.is_impl_trait_in_trait() {
|
||||
return Err(tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
return Err(tcx.dcx().delayed_bug(
|
||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||
));
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use rustc_middle::traits::{ObligationCause, Reveal};
|
||||
use rustc_middle::ty::{
|
||||
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
||||
};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
use rustc_trait_selection::traits::{
|
||||
elaborate, normalize_param_env_or_error, outlives_bounds::InferCtxtExt, ObligationCtxt,
|
||||
};
|
||||
@ -153,10 +153,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
trait_m_sig.inputs_and_output,
|
||||
));
|
||||
if !ocx.select_all_or_error().is_empty() {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (selection)",
|
||||
);
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
|
||||
return;
|
||||
}
|
||||
let outlives_env = OutlivesEnvironment::with_bounds(
|
||||
@ -165,18 +162,12 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
);
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (regions)",
|
||||
);
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)");
|
||||
return;
|
||||
}
|
||||
// Resolve any lifetime variables that may have been introduced during normalization.
|
||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (resolution)",
|
||||
);
|
||||
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (resolution)");
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -4,7 +4,7 @@ use rustc_hir as hir;
|
||||
use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::{Symbol, DUMMY_SP};
|
||||
use rustc_span::Symbol;
|
||||
use rustc_target::abi::FieldIdx;
|
||||
use rustc_target::asm::{InlineAsmReg, InlineAsmRegClass, InlineAsmRegOrRegClass, InlineAsmType};
|
||||
|
||||
@ -294,7 +294,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
pub fn check_asm(&self, asm: &hir::InlineAsm<'tcx>, enclosing_id: LocalDefId) {
|
||||
let target_features = self.tcx.asm_target_features(enclosing_id.to_def_id());
|
||||
let Some(asm_arch) = self.tcx.sess.asm_arch else {
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
||||
self.tcx.dcx().delayed_bug("target architecture does not support asm");
|
||||
return;
|
||||
};
|
||||
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
||||
|
@ -22,7 +22,7 @@ use rustc_middle::ty::{self, TyCtxt, TypeSuperVisitable, TypeVisitor};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::symbol::{sym, Ident};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
use std::fmt;
|
||||
|
||||
use crate::errors;
|
||||
@ -335,13 +335,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||
// though this may happen when we call `poly_trait_ref_binder_info` with
|
||||
// an (erroneous, #113423) associated return type bound in an impl header.
|
||||
if !supertrait_bound_vars.is_empty() {
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!(
|
||||
"found supertrait lifetimes without a binder to append \
|
||||
self.tcx.dcx().delayed_bug(format!(
|
||||
"found supertrait lifetimes without a binder to append \
|
||||
them to: {supertrait_bound_vars:?}"
|
||||
),
|
||||
);
|
||||
));
|
||||
}
|
||||
break (vec![], BinderScopeType::Normal);
|
||||
}
|
||||
|
@ -192,10 +192,10 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
|
||||
// rust-lang/rust#57464: `impl Trait` can leak local
|
||||
// scopes (in manner violating typeck). Therefore, use
|
||||
// `span_delayed_bug` to allow type error over an ICE.
|
||||
canonicalizer.tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
format!("unexpected region in query response: `{r:?}`"),
|
||||
);
|
||||
canonicalizer
|
||||
.tcx
|
||||
.dcx()
|
||||
.delayed_bug(format!("unexpected region in query response: `{r:?}`"));
|
||||
r
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtx
|
||||
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
|
||||
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::fmt;
|
||||
@ -1434,10 +1434,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
bug!("`{value:?}` is not fully resolved");
|
||||
}
|
||||
if value.has_infer_regions() {
|
||||
let guar = self
|
||||
.tcx
|
||||
.dcx()
|
||||
.span_delayed_bug(DUMMY_SP, format!("`{value:?}` is not fully resolved"));
|
||||
let guar =
|
||||
self.tcx.dcx().delayed_bug(format!("`{value:?}` is not fully resolved"));
|
||||
Ok(self.tcx.fold_regions(value, |re, _| {
|
||||
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
|
||||
}))
|
||||
|
@ -1,6 +1,5 @@
|
||||
use rustc_data_structures::undo_log::UndoLogs;
|
||||
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use crate::infer::{InferCtxtUndoLogs, UndoLog};
|
||||
|
||||
@ -40,9 +39,7 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
|
||||
impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
|
||||
fn drop(&mut self) {
|
||||
if !self.opaque_types.is_empty() {
|
||||
ty::tls::with(|tcx| {
|
||||
tcx.dcx().span_delayed_bug(DUMMY_SP, format!("{:?}", self.opaque_types))
|
||||
});
|
||||
ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{:?}", self.opaque_types)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,10 +175,9 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
||||
// ignore this, we presume it will yield an error
|
||||
// later, since if a type variable is not resolved by
|
||||
// this point it never will be
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
format!("unresolved inference variable in outlives: {v:?}"),
|
||||
);
|
||||
self.tcx
|
||||
.dcx()
|
||||
.delayed_bug(format!("unresolved inference variable in outlives: {v:?}"));
|
||||
// add a bound that never holds
|
||||
VerifyBound::AnyBound(vec![])
|
||||
}
|
||||
|
@ -180,10 +180,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
&mut OriginalQueryValues::default(),
|
||||
);
|
||||
self.tcx.check_tys_might_be_eq(canonical).map_err(|_| {
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("cannot relate consts of different types (a={a:?}, b={b:?})",),
|
||||
)
|
||||
self.tcx.dcx().delayed_bug(format!(
|
||||
"cannot relate consts of different types (a={a:?}, b={b:?})",
|
||||
))
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -14,7 +14,6 @@ use either::{Left, Right};
|
||||
|
||||
use rustc_ast::Mutability;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::{Align, HasDataLayout, Size};
|
||||
|
||||
use super::{
|
||||
@ -314,9 +313,7 @@ impl<Prov: Provenance, Bytes: AllocBytes> Allocation<Prov, (), Bytes> {
|
||||
/// available to the compiler to do so.
|
||||
pub fn try_uninit<'tcx>(size: Size, align: Align) -> InterpResult<'tcx, Self> {
|
||||
Self::uninit_inner(size, align, || {
|
||||
ty::tls::with(|tcx| {
|
||||
tcx.dcx().span_delayed_bug(DUMMY_SP, "exhausted memory during interpretation")
|
||||
});
|
||||
ty::tls::with(|tcx| tcx.dcx().delayed_bug("exhausted memory during interpretation"));
|
||||
InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted).into()
|
||||
})
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ macro_rules! define_feedable {
|
||||
// We have an inconsistency. This can happen if one of the two
|
||||
// results is tainted by errors. In this case, delay a bug to
|
||||
// ensure compilation is doomed, and keep the `old` value.
|
||||
tcx.dcx().span_delayed_bug(DUMMY_SP, format!(
|
||||
tcx.dcx().delayed_bug(format!(
|
||||
"Trying to feed an already recorded value for query {} key={key:?}:\n\
|
||||
old value: {old:?}\nnew value: {value:?}",
|
||||
stringify!($name),
|
||||
|
@ -284,7 +284,7 @@ impl<'tcx> LayoutCalculator for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
type TargetDataLayoutRef = &'tcx TargetDataLayout;
|
||||
|
||||
fn delayed_bug(&self, txt: String) {
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, txt);
|
||||
self.tcx.dcx().delayed_bug(txt);
|
||||
}
|
||||
|
||||
fn current_data_layout(&self) -> Self::TargetDataLayoutRef {
|
||||
|
@ -9,7 +9,6 @@ use rustc_middle::thir::*;
|
||||
use rustc_middle::ty::{
|
||||
self, CanonicalUserType, CanonicalUserTypeAnnotation, TyCtxt, UserTypeAnnotationIndex,
|
||||
};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::Size;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
@ -111,15 +110,15 @@ fn lit_to_mir_constant<'tcx>(
|
||||
let LitToConstInput { lit, ty, neg } = lit_input;
|
||||
let trunc = |n| {
|
||||
let param_ty = ty::ParamEnv::reveal_all().and(ty);
|
||||
let width = tcx
|
||||
.layout_of(param_ty)
|
||||
.map_err(|_| {
|
||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("couldn't compute width of literal: {:?}", lit_input.lit),
|
||||
))
|
||||
})?
|
||||
.size;
|
||||
let width =
|
||||
tcx.layout_of(param_ty)
|
||||
.map_err(|_| {
|
||||
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||
"couldn't compute width of literal: {:?}",
|
||||
lit_input.lit
|
||||
)))
|
||||
})?
|
||||
.size;
|
||||
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
||||
let result = width.truncate(n);
|
||||
trace!("trunc result: {}", result);
|
||||
@ -158,16 +157,16 @@ fn lit_to_mir_constant<'tcx>(
|
||||
}
|
||||
(ast::LitKind::Float(n, _), ty::Float(fty)) => parse_float_into_constval(*n, *fty, neg)
|
||||
.ok_or_else(|| {
|
||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("couldn't parse float literal: {:?}", lit_input.lit),
|
||||
))
|
||||
LitToConstError::Reported(
|
||||
tcx.dcx()
|
||||
.delayed_bug(format!("couldn't parse float literal: {:?}", lit_input.lit)),
|
||||
)
|
||||
})?,
|
||||
(ast::LitKind::Bool(b), ty::Bool) => ConstValue::Scalar(Scalar::from_bool(*b)),
|
||||
(ast::LitKind::Char(c), ty::Char) => ConstValue::Scalar(Scalar::from_char(*c)),
|
||||
(ast::LitKind::Err, _) => {
|
||||
return Err(LitToConstError::Reported(
|
||||
tcx.dcx().span_delayed_bug(DUMMY_SP, "encountered LitKind::Err during mir build"),
|
||||
tcx.dcx().delayed_bug("encountered LitKind::Err during mir build"),
|
||||
));
|
||||
}
|
||||
_ => return Err(LitToConstError::TypeError),
|
||||
|
@ -1,7 +1,6 @@
|
||||
use rustc_ast as ast;
|
||||
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
|
||||
use rustc_middle::ty::{self, ParamEnv, ScalarInt, TyCtxt};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use crate::build::parse_float_into_scalar;
|
||||
|
||||
@ -13,15 +12,15 @@ pub(crate) fn lit_to_const<'tcx>(
|
||||
|
||||
let trunc = |n| {
|
||||
let param_ty = ParamEnv::reveal_all().and(ty);
|
||||
let width = tcx
|
||||
.layout_of(param_ty)
|
||||
.map_err(|_| {
|
||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("couldn't compute width of literal: {:?}", lit_input.lit),
|
||||
))
|
||||
})?
|
||||
.size;
|
||||
let width =
|
||||
tcx.layout_of(param_ty)
|
||||
.map_err(|_| {
|
||||
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||
"couldn't compute width of literal: {:?}",
|
||||
lit_input.lit
|
||||
)))
|
||||
})?
|
||||
.size;
|
||||
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
||||
let result = width.truncate(n);
|
||||
trace!("trunc result: {}", result);
|
||||
@ -60,20 +59,21 @@ pub(crate) fn lit_to_const<'tcx>(
|
||||
}
|
||||
(ast::LitKind::Bool(b), ty::Bool) => ty::ValTree::from_scalar_int((*b).into()),
|
||||
(ast::LitKind::Float(n, _), ty::Float(fty)) => {
|
||||
let bits = parse_float_into_scalar(*n, *fty, neg)
|
||||
.ok_or_else(|| {
|
||||
LitToConstError::Reported(tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("couldn't parse float literal: {:?}", lit_input.lit),
|
||||
))
|
||||
})?
|
||||
.assert_int();
|
||||
let bits =
|
||||
parse_float_into_scalar(*n, *fty, neg)
|
||||
.ok_or_else(|| {
|
||||
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||
"couldn't parse float literal: {:?}",
|
||||
lit_input.lit
|
||||
)))
|
||||
})?
|
||||
.assert_int();
|
||||
ty::ValTree::from_scalar_int(bits)
|
||||
}
|
||||
(ast::LitKind::Char(c), ty::Char) => ty::ValTree::from_scalar_int((*c).into()),
|
||||
(ast::LitKind::Err, _) => {
|
||||
return Err(LitToConstError::Reported(
|
||||
tcx.dcx().span_delayed_bug(DUMMY_SP, "encountered LitKind::Err during mir build"),
|
||||
tcx.dcx().delayed_bug("encountered LitKind::Err during mir build"),
|
||||
));
|
||||
}
|
||||
_ => return Err(LitToConstError::TypeError),
|
||||
|
@ -31,7 +31,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
|
||||
|
||||
if !errors.is_empty() {
|
||||
let message = errors.iter().fold(String::new(), |s1, s2| s1 + "\n" + s2);
|
||||
tcx.dcx().span_delayed_bug(rustc_span::DUMMY_SP, message);
|
||||
tcx.dcx().delayed_bug(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,6 @@ use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{self, RootVariableMinCaptureList, Ty, TyCtxt};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use std::io;
|
||||
@ -560,7 +559,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
match self.successors[ln] {
|
||||
Some(successor) => self.assigned_on_entry(successor, var),
|
||||
None => {
|
||||
self.ir.tcx.dcx().span_delayed_bug(DUMMY_SP, "no successor");
|
||||
self.ir.tcx.dcx().delayed_bug("no successor");
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -431,17 +431,14 @@ where
|
||||
// We have an inconsistency. This can happen if one of the two
|
||||
// results is tainted by errors. In this case, delay a bug to
|
||||
// ensure compilation is doomed.
|
||||
qcx.dep_context().sess().dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!(
|
||||
"Computed query value for {:?}({:?}) is inconsistent with fed value,\n\
|
||||
qcx.dep_context().sess().dcx().delayed_bug(format!(
|
||||
"Computed query value for {:?}({:?}) is inconsistent with fed value,\n\
|
||||
computed={:#?}\nfed={:#?}",
|
||||
query.dep_kind(),
|
||||
key,
|
||||
formatter(&result),
|
||||
formatter(&cached_result),
|
||||
),
|
||||
);
|
||||
query.dep_kind(),
|
||||
key,
|
||||
formatter(&result),
|
||||
formatter(&cached_result),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,10 +341,7 @@ impl Session {
|
||||
if self.dcx().err_count() == old_count {
|
||||
Ok(result)
|
||||
} else {
|
||||
Err(self.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
"`self.err_count()` changed but an error was not emitted",
|
||||
))
|
||||
Err(self.dcx().delayed_bug("`self.err_count()` changed but an error was not emitted"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt};
|
||||
use rustc_parse_format::{ParseMode, Parser, Piece, Position};
|
||||
use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
use std::iter;
|
||||
|
||||
use crate::errors::{
|
||||
@ -657,9 +657,7 @@ impl<'tcx> OnUnimplementedDirective {
|
||||
|
||||
Ok(None)
|
||||
} else {
|
||||
let reported = tcx
|
||||
.dcx()
|
||||
.span_delayed_bug(DUMMY_SP, "of_item: neither meta_item_list nor value_str");
|
||||
let reported = tcx.dcx().delayed_bug("of_item: neither meta_item_list nor value_str");
|
||||
return Err(reported);
|
||||
};
|
||||
debug!("of_item({:?}) = {:?}", item_def_id, result);
|
||||
|
@ -228,7 +228,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
self.dcx().span_delayed_bug(DUMMY_SP, "expected fulfillment errors")
|
||||
self.dcx().delayed_bug("expected fulfillment errors")
|
||||
}
|
||||
|
||||
/// Reports that an overflow has occurred and halts compilation. We
|
||||
|
@ -14,7 +14,6 @@ use rustc_infer::traits::Normalized;
|
||||
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
|
||||
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
@ -286,10 +285,8 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
||||
// Rustdoc normalizes possibly not well-formed types, so only
|
||||
// treat this as a bug if we're not in rustdoc.
|
||||
if !tcx.sess.opts.actually_rustdoc {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("unexpected ambiguity: {c_data:?} {result:?}"),
|
||||
);
|
||||
tcx.dcx()
|
||||
.delayed_bug(format!("unexpected ambiguity: {c_data:?} {result:?}"));
|
||||
}
|
||||
return Err(NoSolution);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_infer::infer::region_constraints::RegionConstraintData;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::ty::{TyCtxt, TypeFoldable};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
@ -88,10 +88,9 @@ where
|
||||
if errors.is_empty() {
|
||||
Ok(value)
|
||||
} else {
|
||||
Err(infcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("errors selecting obligation during MIR typeck: {errors:?}"),
|
||||
))
|
||||
Err(infcx
|
||||
.dcx()
|
||||
.delayed_bug(format!("errors selecting obligation during MIR typeck: {errors:?}")))
|
||||
}
|
||||
})?;
|
||||
|
||||
|
@ -11,7 +11,6 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, AdtDef, EarlyBinder, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::*;
|
||||
|
||||
use std::fmt::Debug;
|
||||
@ -91,7 +90,7 @@ fn univariant_uninterned<'tcx>(
|
||||
let dl = cx.data_layout();
|
||||
let pack = repr.pack;
|
||||
if pack.is_some() && repr.align.is_some() {
|
||||
cx.tcx.dcx().span_delayed_bug(DUMMY_SP, "struct cannot be packed and aligned");
|
||||
cx.tcx.dcx().delayed_bug("struct cannot be packed and aligned");
|
||||
return Err(cx.tcx.arena.alloc(LayoutError::Unknown(ty)));
|
||||
}
|
||||
|
||||
@ -344,10 +343,7 @@ fn layout_of_uncached<'tcx>(
|
||||
ty::Adt(def, args) if def.repr().simd() => {
|
||||
if !def.is_struct() {
|
||||
// Should have yielded E0517 by now.
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"#[repr(simd)] was applied to an ADT that is not a struct",
|
||||
);
|
||||
tcx.dcx().delayed_bug("#[repr(simd)] was applied to an ADT that is not a struct");
|
||||
return Err(error(cx, LayoutError::Unknown(ty)));
|
||||
}
|
||||
|
||||
@ -374,8 +370,7 @@ fn layout_of_uncached<'tcx>(
|
||||
// (should be caught by typeck)
|
||||
for fi in fields {
|
||||
if fi.ty(tcx, args) != f0_ty {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
tcx.dcx().delayed_bug(
|
||||
"#[repr(simd)] was applied to an ADT with heterogeneous field type",
|
||||
);
|
||||
return Err(error(cx, LayoutError::Unknown(ty)));
|
||||
|
Loading…
Reference in New Issue
Block a user