From 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:39 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_transmute/src/layout/tree.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'compiler/rustc_transmute/src/layout/tree.rs') diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 295b65c2c..2a89494c8 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -167,31 +167,31 @@ where } } -#[derive(Debug, Copy, Clone)] -pub(crate) enum Err { - /// The layout of the type is unspecified. - Unspecified, - /// This error will be surfaced elsewhere by rustc, so don't surface it. - Unknown, -} - #[cfg(feature = "rustc")] pub(crate) mod rustc { - use super::{Err, Tree}; + use super::Tree; use crate::layout::rustc::{Def, Ref}; - use rustc_middle::ty; use rustc_middle::ty::layout::LayoutError; use rustc_middle::ty::util::Discr; use rustc_middle::ty::AdtDef; use rustc_middle::ty::ParamEnv; use rustc_middle::ty::SubstsRef; - use rustc_middle::ty::Ty; - use rustc_middle::ty::TyCtxt; use rustc_middle::ty::VariantDef; + use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; + use rustc_span::ErrorGuaranteed; use rustc_target::abi::Align; use std::alloc; + #[derive(Debug, Copy, Clone)] + pub(crate) enum Err { + /// The layout of the type is unspecified. + Unspecified, + /// This error will be surfaced elsewhere by rustc, so don't surface it. + Unknown, + TypeError(ErrorGuaranteed), + } + impl<'tcx> From> for Err { fn from(err: LayoutError<'tcx>) -> Self { match err { @@ -261,6 +261,10 @@ pub(crate) mod rustc { use rustc_middle::ty::UintTy::*; use rustc_target::abi::HasDataLayout; + if let Err(e) = ty.error_reported() { + return Err(Err::TypeError(e)); + } + let target = tcx.data_layout(); match ty.kind() { -- cgit v1.2.3