diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-28 22:54:07 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-28 22:54:07 +0000 |
commit | 5df3ee8274fdb7cdeb2b0871b4efea8cbf4724a1 (patch) | |
tree | c1769a152888b97134e3f3811d4504f467ce1047 /crates/hir_ty/src/infer/expr.rs | |
parent | 72457d022d704c47ab9dbfee6a1b29063cc9cc5d (diff) | |
parent | 407196b8c0f23e3ddc26e789b84542b1fd9b0eb8 (diff) |
Merge #7816
7816: Lift Ty::Fn into a struct r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 98bc23173..23d4ac8ef 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -18,8 +18,8 @@ use crate::{ | |||
18 | primitive::{self, UintTy}, | 18 | primitive::{self, UintTy}, |
19 | traits::{FnTrait, InEnvironment}, | 19 | traits::{FnTrait, InEnvironment}, |
20 | utils::{generics, variant_data, Generics}, | 20 | utils::{generics, variant_data, Generics}, |
21 | Binders, CallableDefId, InferTy, Mutability, Obligation, OpaqueTyId, Rawness, Scalar, Substs, | 21 | Binders, CallableDefId, FnPointer, FnSig, InferTy, Mutability, Obligation, OpaqueTyId, Rawness, |
22 | TraitRef, Ty, | 22 | Scalar, Substs, TraitRef, Ty, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | use super::{ | 25 | use super::{ |
@@ -247,13 +247,12 @@ impl<'a> InferenceContext<'a> { | |||
247 | None => self.table.new_type_var(), | 247 | None => self.table.new_type_var(), |
248 | }; | 248 | }; |
249 | sig_tys.push(ret_ty.clone()); | 249 | sig_tys.push(ret_ty.clone()); |
250 | let sig_ty = Ty::FnPtr { | 250 | let sig_ty = Ty::Function(FnPointer { |
251 | num_args: sig_tys.len() as u16 - 1, | 251 | num_args: sig_tys.len() - 1, |
252 | is_varargs: false, | 252 | sig: FnSig { variadic: false }, |
253 | substs: Substs(sig_tys.clone().into()), | 253 | substs: Substs(sig_tys.clone().into()), |
254 | }; | 254 | }); |
255 | let closure_ty = | 255 | let closure_ty = Ty::Closure(self.owner, tgt_expr, Substs::single(sig_ty)); |
256 | Ty::Closure { def: self.owner, expr: tgt_expr, substs: Substs::single(sig_ty) }; | ||
257 | 256 | ||
258 | // Eagerly try to relate the closure type with the expected | 257 | // Eagerly try to relate the closure type with the expected |
259 | // type, otherwise we often won't have enough information to | 258 | // type, otherwise we often won't have enough information to |