Skip to content

MGCA: forbid generic parameters from being in used in the types of type_const items #150614

@BoxyUwU

Description

@BoxyUwU

Support for const generics with types that reference generic parameters is gated behind the generic_const_parameter_types feature gate:

#![feature(adt_const_params, unsized_const_params)]

// This errors as the type in `const N: T` uses generic parameters
fn generic_const_param_ty<T: core::marker::ConstParamTy_, const N: T>() {}

We should enforce the same restriction on const items marked as type_const :

#![feature(adt_const_params, unsized_const_params, min_generic_const_args, generic_const_items)]

#[type_const]
const FOO<T: core::marker::ConstParamTy_>: [T; 0] = [];

This should error due to the type [T; 0] naming generic parameters. Until #150612 is implemented this will also error due to [] not being wrapped in a const block

cc @theemathas we'd talked about you working on this so I've assigned you but if you don't want to work on this anymore just unassign yourself :)

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-min_generic_const_args`#![feature(min_generic_const_args)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions