|
1 | 1 | use rustc_index::vec::IndexVec;
|
| 2 | +use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers}; |
2 | 3 | use rustc_middle::ty::SymbolName;
|
3 | 4 | use rustc_target::abi::call::FnAbi;
|
4 | 5 | use rustc_target::abi::{Integer, Primitive};
|
@@ -256,12 +257,12 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
256 | 257 | pub(crate) inline_asm_index: u32,
|
257 | 258 | }
|
258 | 259 |
|
259 |
| -impl<'tcx> LayoutOf<'tcx> for FunctionCx<'_, '_, 'tcx> { |
260 |
| - type Ty = Ty<'tcx>; |
261 |
| - type TyAndLayout = TyAndLayout<'tcx>; |
| 260 | +impl<'tcx> LayoutOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> { |
| 261 | + type LayoutOfResult = TyAndLayout<'tcx>; |
262 | 262 |
|
263 |
| - fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { |
264 |
| - 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) |
265 | 266 | }
|
266 | 267 | }
|
267 | 268 |
|
@@ -364,19 +365,16 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
|
364 | 365 |
|
365 | 366 | pub(crate) struct RevealAllLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
|
366 | 367 |
|
367 |
| -impl<'tcx> LayoutOf<'tcx> for RevealAllLayoutCx<'tcx> { |
368 |
| - type Ty = Ty<'tcx>; |
369 |
| - type TyAndLayout = TyAndLayout<'tcx>; |
| 368 | +impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> { |
| 369 | + type LayoutOfResult = TyAndLayout<'tcx>; |
370 | 370 |
|
371 |
| - fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { |
372 |
| - assert!(!ty.still_further_specializable()); |
373 |
| - self.0.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap_or_else(|e| { |
374 |
| - if let layout::LayoutError::SizeOverflow(_) = e { |
375 |
| - self.0.sess.fatal(&e.to_string()) |
376 |
| - } else { |
377 |
| - bug!("failed to get layout for `{}`: {}", ty, e) |
378 |
| - } |
379 |
| - }) |
| 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 | + } |
380 | 378 | }
|
381 | 379 | }
|
382 | 380 |
|
|
0 commit comments