summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_transmute/src/layout/tree.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_transmute/src/layout/tree.rs')
-rw-r--r--compiler/rustc_transmute/src/layout/tree.rs28
1 files changed, 16 insertions, 12 deletions
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<LayoutError<'tcx>> 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() {