diff options
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index dbbbce795..85d4dc05c 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -1051,7 +1051,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1051 | Expr::UnaryOp { expr, op } => { | 1051 | Expr::UnaryOp { expr, op } => { |
1052 | let inner_ty = self.infer_expr(*expr, &Expectation::none()); | 1052 | let inner_ty = self.infer_expr(*expr, &Expectation::none()); |
1053 | match op { | 1053 | match op { |
1054 | Some(UnaryOp::Deref) => { | 1054 | UnaryOp::Deref => { |
1055 | if let Some(derefed_ty) = inner_ty.builtin_deref() { | 1055 | if let Some(derefed_ty) = inner_ty.builtin_deref() { |
1056 | derefed_ty | 1056 | derefed_ty |
1057 | } else { | 1057 | } else { |
@@ -1059,7 +1059,20 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1059 | Ty::Unknown | 1059 | Ty::Unknown |
1060 | } | 1060 | } |
1061 | } | 1061 | } |
1062 | _ => Ty::Unknown, | 1062 | UnaryOp::Neg => { |
1063 | match inner_ty { | ||
1064 | Ty::Int(primitive::UncertainIntTy::Unknown) | ||
1065 | | Ty::Int(primitive::UncertainIntTy::Signed(..)) | ||
1066 | | Ty::Infer(InferTy::IntVar(..)) | ||
1067 | | Ty::Infer(InferTy::FloatVar(..)) | ||
1068 | | Ty::Float(..) => inner_ty, | ||
1069 | // TODO: resolve ops::Neg trait | ||
1070 | _ => Ty::Unknown, | ||
1071 | } | ||
1072 | } | ||
1073 | UnaryOp::Not if inner_ty == Ty::Bool => Ty::Bool, | ||
1074 | // TODO: resolve ops::Not trait for inner_ty | ||
1075 | UnaryOp::Not => Ty::Unknown, | ||
1063 | } | 1076 | } |
1064 | } | 1077 | } |
1065 | Expr::BinaryOp { lhs, rhs, op } => match op { | 1078 | Expr::BinaryOp { lhs, rhs, op } => match op { |