Auto merge of #117171 - fee1-dead-contrib:deny-explicit-effect-params, r=oli-obk

Deny providing explicit effect params

r? `@oli-obk`

cc https://github.com/rust-lang/rust/issues/110395
This commit is contained in:
bors 2023-10-26 14:50:23 +00:00
commit 698db856de
8 changed files with 215 additions and 5 deletions

View file

@ -429,6 +429,14 @@ pub(crate) fn check_generic_arg_count(
.filter(|param| matches!(param.kind, ty::GenericParamDefKind::Type { synthetic: true, .. }))
.count();
let named_type_param_count = param_counts.types - has_self as usize - synth_type_param_count;
let synth_const_param_count = gen_params
.params
.iter()
.filter(|param| {
matches!(param.kind, ty::GenericParamDefKind::Const { is_host_effect: true, .. })
})
.count();
let named_const_param_count = param_counts.consts - synth_const_param_count;
let infer_lifetimes =
(gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params();
@ -573,11 +581,13 @@ pub(crate) fn check_generic_arg_count(
debug!(?expected_min);
debug!(arg_counts.lifetimes=?gen_args.num_lifetime_params());
let provided = gen_args.num_generic_params();
check_types_and_consts(
expected_min,
param_counts.consts + named_type_param_count,
param_counts.consts + named_type_param_count + synth_type_param_count,
gen_args.num_generic_params(),
named_const_param_count + named_type_param_count,
named_const_param_count + named_type_param_count + synth_type_param_count,
provided,
param_counts.lifetimes + has_self as usize,
gen_args.num_lifetime_params(),
)