Skip to content

Commit 996905b

Browse files
committed
Refactor FnDecl and FnSig flags into packed structs
1 parent 8a7ac24 commit 996905b

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

crates/hir-ty/src/infer/closure.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ impl<'db> InferenceContext<'_, 'db> {
164164
let coroutine_captures_by_ref_ty = Ty::new_fn_ptr(
165165
interner,
166166
Binder::bind_with_vars(
167-
interner.mk_fn_sig(
168-
[],
169-
self.types.types.unit,
170-
false,
171-
Safety::Safe,
172-
FnAbi::Rust,
173-
),
167+
interner.mk_fn_sig_safe_rust_abi([], self.types.types.unit),
174168
self.types.coroutine_captures_by_ref_bound_var_kinds,
175169
),
176170
);
@@ -484,13 +478,8 @@ impl<'db> InferenceContext<'_, 'db> {
484478
let ret_param_ty = projection.skip_binder().term.expect_type();
485479
debug!(?ret_param_ty);
486480

487-
let sig = projection.rebind(self.interner().mk_fn_sig(
488-
input_tys,
489-
ret_param_ty,
490-
false,
491-
Safety::Safe,
492-
FnAbi::Rust,
493-
));
481+
let sig =
482+
projection.rebind(self.interner().mk_fn_sig_safe_rust_abi(input_tys, ret_param_ty));
494483

495484
Some(sig)
496485
}
@@ -572,13 +561,8 @@ impl<'db> InferenceContext<'_, 'db> {
572561
// that does not misuse a `FnSig` type, but that can be done separately.
573562
let return_ty = return_ty.unwrap_or_else(|| self.table.next_ty_var());
574563

575-
let sig = projection.rebind(self.interner().mk_fn_sig(
576-
input_tys,
577-
return_ty,
578-
false,
579-
Safety::Safe,
580-
FnAbi::Rust,
581-
));
564+
let sig =
565+
projection.rebind(self.interner().mk_fn_sig_safe_rust_abi(input_tys, return_ty));
582566

583567
Some(sig)
584568
}

crates/hir-ty/src/next_solver/interner.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,22 @@ impl<'db> DbInterner<'db> {
23582358
abi,
23592359
}
23602360
}
2361+
2362+
/// `mk_fn_sig`, but with a safe Rust ABI, and no C-variadic argument.
2363+
pub fn mk_fn_sig_safe_rust_abi<I>(self, inputs: I, output: Ty<'db>) -> FnSig<'db>
2364+
where
2365+
I: IntoIterator<Item = Ty<'db>>,
2366+
{
2367+
FnSig {
2368+
inputs_and_output: Tys::new_from_iter(
2369+
self,
2370+
inputs.into_iter().chain(std::iter::once(output)),
2371+
),
2372+
c_variadic: false,
2373+
safety: Safety::Safe,
2374+
abi: FnAbi::Rust,
2375+
}
2376+
}
23612377
}
23622378

23632379
fn predicates_of(db: &dyn HirDatabase, def_id: SolverDefId) -> &GenericPredicates {

0 commit comments

Comments
 (0)