Skip to content

Commit 7719f53

Browse files
committed
Replace structurally_resolved_type in casts check.
The behaviour of `resolve_type_vars_if_possible` is simpler and infallible.
1 parent 5092c6b commit 7719f53

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/librustc/ty/cast.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use syntax::ast;
2020
pub enum IntTy {
2121
U(ast::UintTy),
2222
I,
23-
Ivar,
2423
CEnum,
2524
Bool,
2625
Char
@@ -64,7 +63,7 @@ impl<'tcx> CastTy<'tcx> {
6463
ty::TyBool => Some(CastTy::Int(IntTy::Bool)),
6564
ty::TyChar => Some(CastTy::Int(IntTy::Char)),
6665
ty::TyInt(_) => Some(CastTy::Int(IntTy::I)),
67-
ty::TyInfer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::Ivar)),
66+
ty::TyInfer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::I)),
6867
ty::TyInfer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float),
6968
ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))),
7069
ty::TyFloat(_) => Some(CastTy::Float),

src/librustc_typeck/check/cast.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
389389
}
390390

391391
pub fn check(mut self, fcx: &FnCtxt<'a, 'gcx, 'tcx>) {
392-
self.expr_ty = fcx.structurally_resolved_type(self.span, self.expr_ty);
393-
self.cast_ty = fcx.structurally_resolved_type(self.span, self.cast_ty);
392+
self.expr_ty = fcx.resolve_type_vars_if_possible(&self.expr_ty);
393+
self.cast_ty = fcx.resolve_type_vars_if_possible(&self.cast_ty);
394394

395395
debug!("check_cast({}, {:?} as {:?})",
396396
self.expr.id,
@@ -484,11 +484,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
484484
ty::TypeVariants::TyInfer(t) => {
485485
match t {
486486
ty::InferTy::IntVar(_) |
487-
ty::InferTy::FloatVar(_) |
488-
ty::InferTy::FreshIntTy(_) |
489-
ty::InferTy::FreshFloatTy(_) => {
490-
Err(CastError::NeedDeref)
491-
}
487+
ty::InferTy::FloatVar(_) => Err(CastError::NeedDeref),
492488
_ => Err(CastError::NeedViaPtr),
493489
}
494490
}

0 commit comments

Comments
 (0)