aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r--crates/hir_ty/src/infer/expr.rs30
1 files changed, 25 insertions, 5 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index 605951b10..2cdce2cef 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -137,10 +137,24 @@ impl<'a> InferenceContext<'a> {
137 137
138 self.coerce_merge_branch(&then_ty, &else_ty) 138 self.coerce_merge_branch(&then_ty, &else_ty)
139 } 139 }
140 Expr::Block { statements, tail, .. } => { 140 Expr::Block { statements, tail, label } => match label {
141 // FIXME: Breakable block inference 141 Some(_) => {
142 self.infer_block(statements, *tail, expected) 142 let break_ty = self.table.new_type_var();
143 } 143 self.breakables.push(BreakableContext {
144 may_break: false,
145 break_ty: break_ty.clone(),
146 label: label.clone(),
147 });
148 let ty = self.infer_block(statements, *tail, &Expectation::has_type(break_ty));
149 let ctxt = self.breakables.pop().expect("breakable stack broken");
150 if ctxt.may_break {
151 ctxt.break_ty
152 } else {
153 ty
154 }
155 }
156 None => self.infer_block(statements, *tail, expected),
157 },
144 Expr::Unsafe { body } => self.infer_expr(*body, expected), 158 Expr::Unsafe { body } => self.infer_expr(*body, expected),
145 Expr::TryBlock { body } => { 159 Expr::TryBlock { body } => {
146 let _inner = self.infer_expr(*body, expected); 160 let _inner = self.infer_expr(*body, expected);
@@ -842,12 +856,18 @@ impl<'a> InferenceContext<'a> {
842 // handle provided type arguments 856 // handle provided type arguments
843 if let Some(generic_args) = generic_args { 857 if let Some(generic_args) = generic_args {
844 // if args are provided, it should be all of them, but we can't rely on that 858 // if args are provided, it should be all of them, but we can't rely on that
845 for arg in generic_args.args.iter().take(type_params) { 859 for arg in generic_args
860 .args
861 .iter()
862 .filter(|arg| matches!(arg, GenericArg::Type(_)))
863 .take(type_params)
864 {
846 match arg { 865 match arg {
847 GenericArg::Type(type_ref) => { 866 GenericArg::Type(type_ref) => {
848 let ty = self.make_ty(type_ref); 867 let ty = self.make_ty(type_ref);
849 substs.push(ty); 868 substs.push(ty);
850 } 869 }
870 GenericArg::Lifetime(_) => {}
851 } 871 }
852 } 872 }
853 }; 873 };