Unroll factor in `#[unroll]` attributes should accept any const expr, not just literals
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Related to the #![feature(loop_hints)] attributes: https://github.com/rust-lang/rust/issues/156874
It would be nice if the N in #[unroll(N)] could take an arbitrary const expression, not just an integer literal:
fn foo<const UNROLL_FACTOR: usize>() {
#[unroll(UNROLL_FACTOR)]
loop {
...
}
}
If that's not possible for technical reasons, another possibility would be a std::hint::unroll function which takes a const parameter and a closure:
fn foo<const UNROLL_FACTOR: usize>() {
std::hint::unroll::<UNROLL_FACTOR>(|| loop {
...
});
}
This would make it easier to experiment with different unroll factors without having to duplicate the same function for each unroll factor
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the related #![feature(loop_hints)] issue, #156874, and the current #[unroll] attribute behavior. Determine whether arbitrary const expressions can be accepted or whether the proposed std::hint::unroll alternative is needed. Done means const-generic unroll factors work without duplicating functions, with coverage for the supported form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100