use super::structurally_resolved_type;
use lint;
-use middle::cast::{CastKind, CastTy};
+use middle::def_id::DefId;
use middle::ty::{self, Ty, HasTypeFlags};
-use syntax::ast;
-use syntax::ast::UintTy::{TyU8};
+use middle::ty::cast::{CastKind, CastTy};
use syntax::codemap::Span;
+use rustc_front::hir;
+use syntax::ast;
+use syntax::ast::UintTy::TyU8;
+
/// Reifies a cast check to be checked once we have full type information for
/// a function context.
pub struct CastCheck<'tcx> {
- expr: ast::Expr,
+ expr: hir::Expr,
expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>,
span: Span,
/// fat pointers if their unsize-infos have the same kind.
#[derive(Copy, Clone, PartialEq, Eq)]
enum UnsizeKind<'tcx> {
- Vtable(ast::DefId),
+ Vtable(DefId),
Length,
/// The unsize info of this projection
OfProjection(&'tcx ty::ProjectionTy<'tcx>),
}
impl<'tcx> CastCheck<'tcx> {
- pub fn new(expr: ast::Expr, expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, span: Span)
+ pub fn new(expr: hir::Expr, expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, span: Span)
-> CastCheck<'tcx> {
CastCheck {
expr: expr,
/// can return Ok and create type errors in the fcx rather than returning
/// directly. coercion-cast is handled in check instead of here.
fn do_check<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<CastKind, CastError> {
- use middle::cast::IntTy::*;
- use middle::cast::CastTy::*;
+ use middle::ty::cast::IntTy::*;
+ use middle::ty::cast::CastTy::*;
let (t_from, t_cast) = match (CastTy::from_ty(self.expr_ty),
CastTy::from_ty(self.cast_ty)) {
{
// array-ptr-cast.
- if m_expr.mutbl == ast::MutImmutable && m_cast.mutbl == ast::MutImmutable {
+ if m_expr.mutbl == hir::MutImmutable && m_cast.mutbl == hir::MutImmutable {
if let ty::TyArray(ety, _) = m_expr.ty.sty {
// Due to the limitations of LLVM global constants,
// region pointers end up pointing at copies of