diff options
author | Lukas Wirth <[email protected]> | 2021-02-28 21:12:07 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-02-28 22:53:21 +0000 |
commit | 407196b8c0f23e3ddc26e789b84542b1fd9b0eb8 (patch) | |
tree | 8f088d09b8a7a017335b90aefbc33211568eb4c3 /crates/hir_ty/src/infer/expr.rs | |
parent | 23d7dbfa5e7ba2cebf8c3f79b5d31285d79c1527 (diff) |
Lift FnPointer into a struct
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 13240f790..b75d32b85 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 |