Skip to content

Make sure generic parameters can be unordered internally #61334

Closed
@varkor

Description

@varkor

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:

// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.C-cleanupCategory: PRs that clean code up or issues documenting cleanup.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