Combine OfOpaque and OfProjection
This commit is contained in:
parent
96cb18e864
commit
4b19a2c119
@ -38,7 +38,6 @@
|
|||||||
use rustc_middle::ty::adjustment::AllowTwoPhase;
|
use rustc_middle::ty::adjustment::AllowTwoPhase;
|
||||||
use rustc_middle::ty::cast::{CastKind, CastTy};
|
use rustc_middle::ty::cast::{CastKind, CastTy};
|
||||||
use rustc_middle::ty::error::TypeError;
|
use rustc_middle::ty::error::TypeError;
|
||||||
use rustc_middle::ty::subst::SubstsRef;
|
|
||||||
use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitable, VariantDef};
|
use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitable, VariantDef};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
@ -75,10 +74,8 @@ enum PointerKind<'tcx> {
|
|||||||
VTable(Option<DefId>),
|
VTable(Option<DefId>),
|
||||||
/// Slice
|
/// Slice
|
||||||
Length,
|
Length,
|
||||||
/// The unsize info of this projection
|
/// The unsize info of this projection or opaque type
|
||||||
OfProjection(ty::AliasTy<'tcx>),
|
OfAlias(ty::AliasTy<'tcx>),
|
||||||
/// The unsize info of this opaque ty
|
|
||||||
OfOpaque(DefId, SubstsRef<'tcx>),
|
|
||||||
/// The unsize info of this parameter
|
/// The unsize info of this parameter
|
||||||
OfParam(ty::ParamTy),
|
OfParam(ty::ParamTy),
|
||||||
}
|
}
|
||||||
@ -118,10 +115,7 @@ fn pointer_kind(
|
|||||||
// Pointers to foreign types are thin, despite being unsized
|
// Pointers to foreign types are thin, despite being unsized
|
||||||
ty::Foreign(..) => Some(PointerKind::Thin),
|
ty::Foreign(..) => Some(PointerKind::Thin),
|
||||||
// We should really try to normalize here.
|
// We should really try to normalize here.
|
||||||
ty::Alias(ty::Projection, pi) => Some(PointerKind::OfProjection(pi)),
|
ty::Alias(_, pi) => Some(PointerKind::OfAlias(pi)),
|
||||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
|
|
||||||
Some(PointerKind::OfOpaque(def_id, substs))
|
|
||||||
}
|
|
||||||
ty::Param(p) => Some(PointerKind::OfParam(p)),
|
ty::Param(p) => Some(PointerKind::OfParam(p)),
|
||||||
// Insufficient type information.
|
// Insufficient type information.
|
||||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => None,
|
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => None,
|
||||||
@ -978,11 +972,9 @@ fn check_addr_ptr_cast(
|
|||||||
Some(PointerKind::Thin) => Ok(CastKind::AddrPtrCast),
|
Some(PointerKind::Thin) => Ok(CastKind::AddrPtrCast),
|
||||||
Some(PointerKind::VTable(_)) => Err(CastError::IntToFatCast(Some("a vtable"))),
|
Some(PointerKind::VTable(_)) => Err(CastError::IntToFatCast(Some("a vtable"))),
|
||||||
Some(PointerKind::Length) => Err(CastError::IntToFatCast(Some("a length"))),
|
Some(PointerKind::Length) => Err(CastError::IntToFatCast(Some("a length"))),
|
||||||
Some(
|
Some(PointerKind::OfAlias(_) | PointerKind::OfParam(_)) => {
|
||||||
PointerKind::OfProjection(_)
|
Err(CastError::IntToFatCast(None))
|
||||||
| PointerKind::OfOpaque(_, _)
|
}
|
||||||
| PointerKind::OfParam(_),
|
|
||||||
) => Err(CastError::IntToFatCast(None)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user