1
Fork 0

Add with_opt_const_effect_param helper, simplify

This commit is contained in:
Michael Goulet 2023-11-28 21:17:55 +00:00
parent 89c2c85fe1
commit d3404d2b98
7 changed files with 37 additions and 30 deletions

View file

@ -813,6 +813,23 @@ impl<'tcx> TyCtxt<'tcx> {
None => self.consts.true_,
}
}
/// Constructs generic args for an item, optionally appending a const effect param type
pub fn with_opt_const_effect_param(
self,
caller_def_id: LocalDefId,
callee_def_id: DefId,
args: impl IntoIterator<Item: Into<ty::GenericArg<'tcx>>>,
) -> ty::GenericArgsRef<'tcx> {
let generics = self.generics_of(callee_def_id);
assert_eq!(generics.parent, None);
let opt_const_param = generics.host_effect_index.is_some().then(|| {
ty::GenericArg::from(self.expected_const_effect_param_for_body(caller_def_id))
});
self.mk_args_from_iter(args.into_iter().map(|arg| arg.into()).chain(opt_const_param))
}
}
struct OpaqueTypeExpander<'tcx> {