|
1 | 1 | use rustc_index::vec::IndexVec;
|
| 2 | +use rustc_middle::ty::layout::LayoutError; |
2 | 3 | use rustc_middle::ty::SymbolName;
|
3 | 4 | use rustc_target::abi::call::FnAbi;
|
4 | 5 | use rustc_target::abi::{Integer, Primitive};
|
@@ -259,8 +260,9 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
259 | 260 | impl<'tcx> LayoutOf<'tcx> for FunctionCx<'_, '_, 'tcx> {
|
260 | 261 | type LayoutOfResult = TyAndLayout<'tcx>;
|
261 | 262 |
|
262 |
| - fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { |
263 |
| - RevealAllLayoutCx(self.tcx).layout_of(ty) |
| 263 | + #[inline] |
| 264 | + fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { |
| 265 | + RevealAllLayoutCx(self.tcx).handle_layout_err(err, span, ty) |
264 | 266 | }
|
265 | 267 | }
|
266 | 268 |
|
@@ -366,15 +368,13 @@ pub(crate) struct RevealAllLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
|
366 | 368 | impl<'tcx> LayoutOf<'tcx> for RevealAllLayoutCx<'tcx> {
|
367 | 369 | type LayoutOfResult = TyAndLayout<'tcx>;
|
368 | 370 |
|
369 |
| - fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { |
370 |
| - assert!(!ty.still_further_specializable()); |
371 |
| - self.0.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap_or_else(|e| { |
372 |
| - if let layout::LayoutError::SizeOverflow(_) = e { |
373 |
| - self.0.sess.fatal(&e.to_string()) |
374 |
| - } else { |
375 |
| - bug!("failed to get layout for `{}`: {}", ty, e) |
376 |
| - } |
377 |
| - }) |
| 371 | + #[inline] |
| 372 | + fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { |
| 373 | + if let layout::LayoutError::SizeOverflow(_) = err { |
| 374 | + self.0.sess.span_fatal(span, &err.to_string()) |
| 375 | + } else { |
| 376 | + span_bug!(span, "failed to get layout for `{}`: {}", ty, err) |
| 377 | + } |
378 | 378 | }
|
379 | 379 | }
|
380 | 380 |
|
|
0 commit comments