diff options
Diffstat (limited to 'crates/ra_hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 22884522a..731b062c2 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | autoderef, method_resolution, op, | 17 | autoderef, method_resolution, op, |
18 | traits::{FnTrait, InEnvironment}, | 18 | traits::{FnTrait, InEnvironment}, |
19 | utils::{generics, variant_data, Generics}, | 19 | utils::{generics, variant_data, Generics}, |
20 | ApplicationTy, Binders, CallableDef, InferTy, IntTy, Mutability, Obligation, Rawness, Substs, | 20 | ApplicationTy, Binders, CallableDefId, InferTy, IntTy, Mutability, Obligation, Rawness, Substs, |
21 | TraitRef, Ty, TypeCtor, | 21 | TraitRef, Ty, TypeCtor, |
22 | }; | 22 | }; |
23 | 23 | ||
@@ -85,10 +85,8 @@ impl<'a> InferenceContext<'a> { | |||
85 | ctor: TypeCtor::Tuple { cardinality: num_args as u16 }, | 85 | ctor: TypeCtor::Tuple { cardinality: num_args as u16 }, |
86 | parameters, | 86 | parameters, |
87 | }); | 87 | }); |
88 | let substs = Substs::build_for_generics(&generic_params) | 88 | let substs = |
89 | .push(ty.clone()) | 89 | Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); |
90 | .push(arg_ty.clone()) | ||
91 | .build(); | ||
92 | 90 | ||
93 | let trait_env = Arc::clone(&self.trait_env); | 91 | let trait_env = Arc::clone(&self.trait_env); |
94 | let implements_fn_trait = | 92 | let implements_fn_trait = |
@@ -222,7 +220,7 @@ impl<'a> InferenceContext<'a> { | |||
222 | }; | 220 | }; |
223 | sig_tys.push(ret_ty.clone()); | 221 | sig_tys.push(ret_ty.clone()); |
224 | let sig_ty = Ty::apply( | 222 | let sig_ty = Ty::apply( |
225 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, | 223 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1, is_varargs: false }, |
226 | Substs(sig_tys.clone().into()), | 224 | Substs(sig_tys.clone().into()), |
227 | ); | 225 | ); |
228 | let closure_ty = | 226 | let closure_ty = |
@@ -407,8 +405,15 @@ impl<'a> InferenceContext<'a> { | |||
407 | .subst(&a_ty.parameters) | 405 | .subst(&a_ty.parameters) |
408 | }) | 406 | }) |
409 | } | 407 | } |
410 | // FIXME: | 408 | TypeCtor::Adt(AdtId::UnionId(u)) => { |
411 | TypeCtor::Adt(AdtId::UnionId(_)) => None, | 409 | self.db.union_data(u).variant_data.field(name).map(|local_id| { |
410 | let field = FieldId { parent: u.into(), local_id }; | ||
411 | self.write_field_resolution(tgt_expr, field); | ||
412 | self.db.field_types(u.into())[field.local_id] | ||
413 | .clone() | ||
414 | .subst(&a_ty.parameters) | ||
415 | }) | ||
416 | } | ||
412 | _ => None, | 417 | _ => None, |
413 | }, | 418 | }, |
414 | _ => None, | 419 | _ => None, |
@@ -849,7 +854,7 @@ impl<'a> InferenceContext<'a> { | |||
849 | } | 854 | } |
850 | // add obligation for trait implementation, if this is a trait method | 855 | // add obligation for trait implementation, if this is a trait method |
851 | match def { | 856 | match def { |
852 | CallableDef::FunctionId(f) => { | 857 | CallableDefId::FunctionId(f) => { |
853 | if let AssocContainerId::TraitId(trait_) = | 858 | if let AssocContainerId::TraitId(trait_) = |
854 | f.lookup(self.db.upcast()).container | 859 | f.lookup(self.db.upcast()).container |
855 | { | 860 | { |
@@ -860,7 +865,7 @@ impl<'a> InferenceContext<'a> { | |||
860 | self.obligations.push(Obligation::Trait(TraitRef { trait_, substs })); | 865 | self.obligations.push(Obligation::Trait(TraitRef { trait_, substs })); |
861 | } | 866 | } |
862 | } | 867 | } |
863 | CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {} | 868 | CallableDefId::StructId(_) | CallableDefId::EnumVariantId(_) => {} |
864 | } | 869 | } |
865 | } | 870 | } |
866 | } | 871 | } |