diff options
Diffstat (limited to 'crates/ra_hir/src/expr')
-rw-r--r-- | crates/ra_hir/src/expr/validation.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index f5e641557..0e7b08c54 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -102,14 +102,16 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
102 | } | 102 | } |
103 | 103 | ||
104 | fn validate_results_in_tail_expr(&mut self, id: ExprId, db: &impl HirDatabase) { | 104 | fn validate_results_in_tail_expr(&mut self, id: ExprId, db: &impl HirDatabase) { |
105 | let expr_ty = &self.infer[id]; | 105 | let mismatch = match self.infer.type_mismatch_for_expr(id) { |
106 | let func_ty = self.func.ty(db); | 106 | Some(m) => m, |
107 | let func_sig = func_ty.callable_sig(db).unwrap(); | 107 | None => return, |
108 | let ret = func_sig.ret(); | 108 | }; |
109 | let ret = match ret { | 109 | |
110 | let ret = match &mismatch.expected { | ||
110 | Ty::Apply(t) => t, | 111 | Ty::Apply(t) => t, |
111 | _ => return, | 112 | _ => return, |
112 | }; | 113 | }; |
114 | |||
113 | let ret_enum = match ret.ctor { | 115 | let ret_enum = match ret.ctor { |
114 | TypeCtor::Adt(AdtDef::Enum(e)) => e, | 116 | TypeCtor::Adt(AdtDef::Enum(e)) => e, |
115 | _ => return, | 117 | _ => return, |
@@ -119,7 +121,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
119 | return; | 121 | return; |
120 | } | 122 | } |
121 | let params = &ret.parameters; | 123 | let params = &ret.parameters; |
122 | if params.len() == 2 && ¶ms[0] == expr_ty { | 124 | if params.len() == 2 && ¶ms[0] == &mismatch.actual { |
123 | let source_map = self.func.body_source_map(db); | 125 | let source_map = self.func.body_source_map(db); |
124 | let file_id = self.func.source(db).file_id; | 126 | let file_id = self.func.source(db).file_id; |
125 | let parse = db.parse(file_id.original_file(db)); | 127 | let parse = db.parse(file_id.original_file(db)); |