-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
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
// FIXME(const_generics): we shouldn't have to abort here at all, but we currently get ICEs | |
// if we don't. Const parameters and type parameters can currently conflict if they | |
// are out-of-order. | |
if !out_of_order.is_empty() && found_type && found_const { | |
FatalError.raise(); | |
} |
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.