-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MGCA: Support array expressions as direct const arguments #150612
Copy link
Copy link
Closed
Labels
A-AST-loweringArea: AST lowering (AST → HIR)Area: AST lowering (AST → HIR)A-HIR-ty-loweringArea: HIR ty lowering (HIR → middle::ty IR)Area: HIR ty lowering (HIR → middle::ty IR)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call 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)]``#![feature(min_generic_const_args)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Metadata
Metadata
Assignees
Labels
A-AST-loweringArea: AST lowering (AST → HIR)Area: AST lowering (AST → HIR)A-HIR-ty-loweringArea: HIR ty lowering (HIR → middle::ty IR)Area: HIR ty lowering (HIR → middle::ty IR)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call 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)]``#![feature(min_generic_const_args)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
We should support array expressions as direct const arguments so that array types as const generics work nicely.
These should lower directly to a
ConstKind::Valuein HIR ty lowering.Supporting array repeat expression, e.g.
takes_array::<{ [N; 3] }>();is more complex as we can't lower to aConstKind::Value. It should be done separately from the previous change.We can possibly shoehorn this into the
ConstKind::Unevaluatedby defining a const item such asconst REPEAT<T, const E: T, const N: usize>: [T, N] = [E; N];. This likely has to wait untilfeature(generic_const_args)exists. It's unclear how lowering the argument to theTtype parameter should work as we can't try to solve aConstArgHasType(E, ?x)goal to produce the inferred?x.Alternatively this could motivate a
ConstKind::Exprvariant.