Make sure generic parameters can be unordered internally #61334
Labels
C-bug
Category: This is a bug.
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Although we currently require generic parameters to be ordered — lifetimes, types, consts — internally there should be no such restriction (other than the error message). However, currently we also require generic parameters to be ordered this way internally. This has caused issues in the past, for example:
rust/src/librustc_passes/ast_validation.rs
Lines 441 to 446 in 9c9b7b4
and #61333. Requiring ordering causes pain points like these, without making anything easier to deal with.
The compiler has got better at handling these now that all parameters are stored in a single vector, but they still need to be ordered in some locations. To fix this, it's probably simplest to add a feature gate
unordered_generic_params
which disables the order check and trace exactly what requires the parameters to be sorted, removing those restrictions. The feature flag will allow us to add regression tests.The text was updated successfully, but these errors were encountered: