diff options
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 5ea2e5934..4e4f6e5a4 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -593,11 +593,11 @@ impl<'a> InferenceContext<'a> { | |||
593 | UnaryOp::Neg => { | 593 | UnaryOp::Neg => { |
594 | match inner_ty.kind(&Interner) { | 594 | match inner_ty.kind(&Interner) { |
595 | // Fast path for builtins | 595 | // Fast path for builtins |
596 | TyKind::Scalar(Scalar::Int(_)) | 596 | TyKind::Scalar(Scalar::Int(_) | Scalar::Uint(_) | Scalar::Float(_)) |
597 | | TyKind::Scalar(Scalar::Uint(_)) | 597 | | TyKind::InferenceVar( |
598 | | TyKind::Scalar(Scalar::Float(_)) | 598 | _, |
599 | | TyKind::InferenceVar(_, TyVariableKind::Integer) | 599 | TyVariableKind::Integer | TyVariableKind::Float, |
600 | | TyKind::InferenceVar(_, TyVariableKind::Float) => inner_ty, | 600 | ) => inner_ty, |
601 | // Otherwise we resolve via the std::ops::Neg trait | 601 | // Otherwise we resolve via the std::ops::Neg trait |
602 | _ => self | 602 | _ => self |
603 | .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()), | 603 | .resolve_associated_type(inner_ty, self.resolve_ops_neg_output()), |
@@ -606,9 +606,7 @@ impl<'a> InferenceContext<'a> { | |||
606 | UnaryOp::Not => { | 606 | UnaryOp::Not => { |
607 | match inner_ty.kind(&Interner) { | 607 | match inner_ty.kind(&Interner) { |
608 | // Fast path for builtins | 608 | // Fast path for builtins |
609 | TyKind::Scalar(Scalar::Bool) | 609 | TyKind::Scalar(Scalar::Bool | Scalar::Int(_) | Scalar::Uint(_)) |
610 | | TyKind::Scalar(Scalar::Int(_)) | ||
611 | | TyKind::Scalar(Scalar::Uint(_)) | ||
612 | | TyKind::InferenceVar(_, TyVariableKind::Integer) => inner_ty, | 610 | | TyKind::InferenceVar(_, TyVariableKind::Integer) => inner_ty, |
613 | // Otherwise we resolve via the std::ops::Not trait | 611 | // Otherwise we resolve via the std::ops::Not trait |
614 | _ => self | 612 | _ => self |
@@ -735,7 +733,7 @@ impl<'a> InferenceContext<'a> { | |||
735 | Expr::Array(array) => { | 733 | Expr::Array(array) => { |
736 | let elem_ty = | 734 | let elem_ty = |
737 | match expected.to_option(&mut self.table).as_ref().map(|t| t.kind(&Interner)) { | 735 | match expected.to_option(&mut self.table).as_ref().map(|t| t.kind(&Interner)) { |
738 | Some(TyKind::Array(st, _)) | Some(TyKind::Slice(st)) => st.clone(), | 736 | Some(TyKind::Array(st, _) | TyKind::Slice(st)) => st.clone(), |
739 | _ => self.table.new_type_var(), | 737 | _ => self.table.new_type_var(), |
740 | }; | 738 | }; |
741 | 739 | ||