Skip to content

Commit 6d43d60

Browse files
committed
abi: use span_bug! over bug! wherever a Span is available.
1 parent 111bebd commit 6d43d60

File tree

1 file changed

+13
-6
lines changed
  • crates/rustc_codegen_spirv/src

1 file changed

+13
-6
lines changed

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use rspirv::spirv::{StorageClass, Word};
88
use rustc_data_structures::fx::FxHashMap;
99
use rustc_errors::ErrorReported;
1010
use rustc_index::vec::Idx;
11-
use rustc_middle::bug;
1211
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
1312
use rustc_middle::ty::query::Providers;
1413
use rustc_middle::ty::subst::SubstsRef;
1514
use rustc_middle::ty::{
1615
self, Const, FloatTy, GeneratorSubsts, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
1716
TypeAndMut, UintTy,
1817
};
18+
use rustc_middle::{bug, span_bug};
1919
use rustc_span::def_id::DefId;
2020
use rustc_span::Span;
2121
use rustc_span::DUMMY_SP;
@@ -152,7 +152,9 @@ impl<'tcx> RecursivePointeeCache<'tcx> {
152152
) -> Word {
153153
match self.map.borrow_mut().entry(pointee) {
154154
// We should have hit begin() on this type already, which always inserts an entry.
155-
Entry::Vacant(_) => bug!("RecursivePointeeCache::end should always have entry"),
155+
Entry::Vacant(_) => {
156+
span_bug!(span, "RecursivePointeeCache::end should always have entry")
157+
}
156158
Entry::Occupied(mut entry) => match *entry.get() {
157159
// State: There have been no recursive references to this type while defining it, and so no
158160
// OpTypeForwardPointer has been emitted. This is the most common case.
@@ -174,7 +176,7 @@ impl<'tcx> RecursivePointeeCache<'tcx> {
174176
.def_with_id(cx, span, id)
175177
}
176178
PointeeDefState::Defined(_) => {
177-
bug!("RecursivePointeeCache::end defined pointer twice")
179+
span_bug!(span, "RecursivePointeeCache::end defined pointer twice")
178180
}
179181
},
180182
}
@@ -466,7 +468,11 @@ pub fn scalar_pair_element_backend_type<'tcx>(
466468
) -> Word {
467469
let [a, b] = match &ty.layout.abi {
468470
Abi::ScalarPair(a, b) => [a, b],
469-
other => bug!("scalar_pair_element_backend_type invalid abi: {:?}", other),
471+
other => span_bug!(
472+
span,
473+
"scalar_pair_element_backend_type invalid abi: {:?}",
474+
other
475+
),
470476
};
471477
let offset = match index {
472478
0 => Size::ZERO,
@@ -595,7 +601,8 @@ fn dig_scalar_pointee<'tcx>(
595601

596602
fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -> Word {
597603
match ty.fields {
598-
FieldsShape::Primitive => bug!(
604+
FieldsShape::Primitive => span_bug!(
605+
span,
599606
"trans_aggregate called for FieldsShape::Primitive layout {:#?}",
600607
ty
601608
),
@@ -700,7 +707,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
700707
} else {
701708
if let TyKind::Adt(_, _) = ty.ty.kind() {
702709
} else {
703-
bug!("Variants::Multiple not TyKind::Adt");
710+
span_bug!(span, "Variants::Multiple not TyKind::Adt");
704711
}
705712
if i == 0 {
706713
field_names.push("discriminant".to_string());

0 commit comments

Comments
 (0)