Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir-ty/src/infer/closure.rs | 26 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/interner.rs | 16 |
2 files changed, 21 insertions, 21 deletions
diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs index ce99016470..b868f02342 100644 --- a/crates/hir-ty/src/infer/closure.rs +++ b/crates/hir-ty/src/infer/closure.rs @@ -164,13 +164,7 @@ impl<'db> InferenceContext<'_, 'db> { let coroutine_captures_by_ref_ty = Ty::new_fn_ptr( interner, Binder::bind_with_vars( - interner.mk_fn_sig( - [], - self.types.types.unit, - false, - Safety::Safe, - FnAbi::Rust, - ), + interner.mk_fn_sig_safe_rust_abi([], self.types.types.unit), self.types.coroutine_captures_by_ref_bound_var_kinds, ), ); @@ -484,13 +478,8 @@ impl<'db> InferenceContext<'_, 'db> { let ret_param_ty = projection.skip_binder().term.expect_type(); debug!(?ret_param_ty); - let sig = projection.rebind(self.interner().mk_fn_sig( - input_tys, - ret_param_ty, - false, - Safety::Safe, - FnAbi::Rust, - )); + let sig = + projection.rebind(self.interner().mk_fn_sig_safe_rust_abi(input_tys, ret_param_ty)); Some(sig) } @@ -572,13 +561,8 @@ impl<'db> InferenceContext<'_, 'db> { // that does not misuse a `FnSig` type, but that can be done separately. let return_ty = return_ty.unwrap_or_else(|| self.table.next_ty_var()); - let sig = projection.rebind(self.interner().mk_fn_sig( - input_tys, - return_ty, - false, - Safety::Safe, - FnAbi::Rust, - )); + let sig = + projection.rebind(self.interner().mk_fn_sig_safe_rust_abi(input_tys, return_ty)); Some(sig) } diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs index 622648bc8d..5d7ad84e1f 100644 --- a/crates/hir-ty/src/next_solver/interner.rs +++ b/crates/hir-ty/src/next_solver/interner.rs @@ -2358,6 +2358,22 @@ impl<'db> DbInterner<'db> { abi, } } + + /// `mk_fn_sig`, but with a safe Rust ABI, and no C-variadic argument. + pub fn mk_fn_sig_safe_rust_abi<I>(self, inputs: I, output: Ty<'db>) -> FnSig<'db> + where + I: IntoIterator<Item = Ty<'db>>, + { + FnSig { + inputs_and_output: Tys::new_from_iter( + self, + inputs.into_iter().chain(std::iter::once(output)), + ), + c_variadic: false, + safety: Safety::Safe, + abi: FnAbi::Rust, + } + } } fn predicates_of(db: &dyn HirDatabase, def_id: SolverDefId) -> &GenericPredicates { |