diff options
Diffstat (limited to 'crates/ra_hir_ty/src/infer.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer.rs | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 8d5b7c943..dec6bd84c 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -34,7 +34,6 @@ use hir_expand::{diagnostics::DiagnosticSink, name::name}; | |||
34 | use ra_arena::map::ArenaMap; | 34 | use ra_arena::map::ArenaMap; |
35 | use ra_prof::profile; | 35 | use ra_prof::profile; |
36 | use ra_syntax::SmolStr; | 36 | use ra_syntax::SmolStr; |
37 | use test_utils::tested_by; | ||
38 | 37 | ||
39 | use super::{ | 38 | use super::{ |
40 | primitive::{FloatTy, IntTy}, | 39 | primitive::{FloatTy, IntTy}, |
@@ -289,29 +288,6 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
289 | self.make_ty_with_mode(type_ref, ImplTraitLoweringMode::Disallowed) | 288 | self.make_ty_with_mode(type_ref, ImplTraitLoweringMode::Disallowed) |
290 | } | 289 | } |
291 | 290 | ||
292 | /// Replaces `impl Trait` in `ty` by type variables and obligations for | ||
293 | /// those variables. This is done for function arguments when calling a | ||
294 | /// function, and for return types when inside the function body, i.e. in | ||
295 | /// the cases where the `impl Trait` is 'transparent'. In other cases, `impl | ||
296 | /// Trait` is represented by `Ty::Opaque`. | ||
297 | fn insert_vars_for_impl_trait(&mut self, ty: Ty) -> Ty { | ||
298 | ty.fold(&mut |ty| match ty { | ||
299 | Ty::Opaque(preds) => { | ||
300 | tested_by!(insert_vars_for_impl_trait); | ||
301 | let var = self.table.new_type_var(); | ||
302 | let var_subst = Substs::builder(1).push(var.clone()).build(); | ||
303 | self.obligations.extend( | ||
304 | preds | ||
305 | .iter() | ||
306 | .map(|pred| pred.clone().subst_bound_vars(&var_subst)) | ||
307 | .filter_map(Obligation::from_predicate), | ||
308 | ); | ||
309 | var | ||
310 | } | ||
311 | _ => ty, | ||
312 | }) | ||
313 | } | ||
314 | |||
315 | /// Replaces Ty::Unknown by a new type var, so we can maybe still infer it. | 291 | /// Replaces Ty::Unknown by a new type var, so we can maybe still infer it. |
316 | fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty { | 292 | fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty { |
317 | match ty { | 293 | match ty { |
@@ -487,8 +463,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
487 | 463 | ||
488 | self.infer_pat(*pat, &ty, BindingMode::default()); | 464 | self.infer_pat(*pat, &ty, BindingMode::default()); |
489 | } | 465 | } |
490 | let return_ty = self.make_ty_with_mode(&data.ret_type, ImplTraitLoweringMode::Variable); | 466 | let return_ty = self.make_ty_with_mode(&data.ret_type, ImplTraitLoweringMode::Disallowed); // FIXME implement RPIT |
491 | self.return_ty = self.insert_vars_for_impl_trait(return_ty); | 467 | self.return_ty = return_ty; |
492 | } | 468 | } |
493 | 469 | ||
494 | fn infer_body(&mut self) { | 470 | fn infer_body(&mut self) { |