Skip to content

Commit 4b19a2c

Browse files
Combine OfOpaque and OfProjection
1 parent 96cb18e commit 4b19a2c

File tree

1 file changed

+6
-14
lines changed
  • compiler/rustc_hir_typeck/src

1 file changed

+6
-14
lines changed

compiler/rustc_hir_typeck/src/cast.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use rustc_middle::mir::Mutability;
3838
use rustc_middle::ty::adjustment::AllowTwoPhase;
3939
use rustc_middle::ty::cast::{CastKind, CastTy};
4040
use rustc_middle::ty::error::TypeError;
41-
use rustc_middle::ty::subst::SubstsRef;
4241
use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitable, VariantDef};
4342
use rustc_session::lint;
4443
use rustc_session::Session;
@@ -75,10 +74,8 @@ enum PointerKind<'tcx> {
7574
VTable(Option<DefId>),
7675
/// Slice
7776
Length,
78-
/// The unsize info of this projection
79-
OfProjection(ty::AliasTy<'tcx>),
80-
/// The unsize info of this opaque ty
81-
OfOpaque(DefId, SubstsRef<'tcx>),
77+
/// The unsize info of this projection or opaque type
78+
OfAlias(ty::AliasTy<'tcx>),
8279
/// The unsize info of this parameter
8380
OfParam(ty::ParamTy),
8481
}
@@ -118,10 +115,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
118115
// Pointers to foreign types are thin, despite being unsized
119116
ty::Foreign(..) => Some(PointerKind::Thin),
120117
// We should really try to normalize here.
121-
ty::Alias(ty::Projection, pi) => Some(PointerKind::OfProjection(pi)),
122-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
123-
Some(PointerKind::OfOpaque(def_id, substs))
124-
}
118+
ty::Alias(_, pi) => Some(PointerKind::OfAlias(pi)),
125119
ty::Param(p) => Some(PointerKind::OfParam(p)),
126120
// Insufficient type information.
127121
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => None,
@@ -978,11 +972,9 @@ impl<'a, 'tcx> CastCheck<'tcx> {
978972
Some(PointerKind::Thin) => Ok(CastKind::AddrPtrCast),
979973
Some(PointerKind::VTable(_)) => Err(CastError::IntToFatCast(Some("a vtable"))),
980974
Some(PointerKind::Length) => Err(CastError::IntToFatCast(Some("a length"))),
981-
Some(
982-
PointerKind::OfProjection(_)
983-
| PointerKind::OfOpaque(_, _)
984-
| PointerKind::OfParam(_),
985-
) => Err(CastError::IntToFatCast(None)),
975+
Some(PointerKind::OfAlias(_) | PointerKind::OfParam(_)) => {
976+
Err(CastError::IntToFatCast(None))
977+
}
986978
}
987979
}
988980

0 commit comments

Comments
 (0)