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:
Nicholas Nethercote 2024-01-04 12:54:23 +11:00
parent 3c4f1d85af
commit 2ea7a37e11
27 changed files with 103 additions and 146 deletions

View file

@ -27,7 +27,7 @@
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 @@ pub fn new(tcx: TyCtxt<'tcx>) -> Self {
#[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 {

View file

@ -391,10 +391,10 @@ fn load_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,

View file

@ -865,10 +865,16 @@ pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMess
/// 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 @@ pub fn span_delayed_bug(
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

View file

@ -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"));
}
}
}

View file

@ -19,7 +19,7 @@
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 @@ fn try_fold_region(
.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",
));
}

View file

@ -7,7 +7,7 @@
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;
};

View file

@ -4,7 +4,7 @@
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 @@ fn check_asm_operand_type(
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() {

View file

@ -22,7 +22,7 @@
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 @@ fn poly_trait_ref_binder_info(&mut self) -> (Vec<ty::BoundVariableKind>, BinderS
// 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);
}

View file

@ -192,10 +192,10 @@ fn canonicalize_free_region<'tcx>(
// 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
}
}

View file

@ -38,7 +38,7 @@
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 @@ pub fn fully_resolve<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> FixupRes
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 }
}))

View file

@ -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 @@ pub(crate) fn with_log<'a>(
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)));
}
}
}

View file

@ -175,10 +175,9 @@ fn bound_from_single_component(
// 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![])
}

View file

@ -180,10 +180,9 @@ pub fn super_combine_consts<R>(
&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:?})",
))
})
});

View file

@ -14,7 +14,6 @@
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 @@ fn uninit_inner<R>(size: Size, align: Align, fail: impl FnOnce() -> R) -> Result
/// 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()
})
}

View file

@ -551,7 +551,7 @@ pub fn $name(self, value: queries::$name::ProvidedValue<'tcx>) {
// 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),

View file

@ -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 {

View file

@ -9,7 +9,6 @@
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),

View file

@ -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),

View file

@ -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);
}
}
}

View file

@ -98,7 +98,6 @@
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 @@ fn assigned_on_exit(&self, ln: LiveNode, var: Variable) -> bool {
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
}
}

View file

@ -431,17 +431,14 @@ fn execute_job<Q, Qcx, const INCR: bool>(
// 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),
));
}
}
}

View file

@ -341,10 +341,7 @@ pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorGuaranteed>
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"))
}
}

View file

@ -14,7 +14,7 @@
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 @@ fn parse_attribute(
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);

View file

@ -228,7 +228,7 @@ struct ErrorDescriptor<'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

View file

@ -14,7 +14,6 @@
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 @@ fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
// 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);
}

View file

@ -6,7 +6,7 @@
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 @@ pub fn scrape_region_constraints<'tcx, Op, R>(
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:?}")))
}
})?;

View file

@ -11,7 +11,6 @@
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)));