use crate::ty::{self, Ty};
-use syntax::ast;
use rustc_macros::HashStable;
+use syntax::ast;
/// Types that are represented as ints.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
I,
CEnum,
Bool,
- Char
+ Char,
}
// Valid types for the result of a non-coercion cast
FnPtr,
/// Raw pointers
Ptr(ty::TypeAndMut<'tcx>),
- /// References
- RPtr(ty::TypeAndMut<'tcx>),
}
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
U8CharCast,
ArrayPtrCast,
FnPtrPtrCast,
- FnPtrAddrCast
+ FnPtrAddrCast,
}
impl<'tcx> CastTy<'tcx> {
ty::Infer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float),
ty::Uint(u) => Some(CastTy::Int(IntTy::U(u))),
ty::Float(_) => Some(CastTy::Float),
- ty::Adt(d,_) if d.is_enum() && d.is_payloadfree() =>
- Some(CastTy::Int(IntTy::CEnum)),
+ ty::Adt(d, _) if d.is_enum() && d.is_payloadfree() => Some(CastTy::Int(IntTy::CEnum)),
ty::RawPtr(mt) => Some(CastTy::Ptr(mt)),
- ty::Ref(_, ty, mutbl) => Some(CastTy::RPtr(ty::TypeAndMut { ty, mutbl })),
ty::FnPtr(..) => Some(CastTy::FnPtr),
_ => None,
}