Skip to content

Unstable type parameters on stable types #2

Closed

Description

This is related to #1 but not identical. When adding a defaulted type parameter to a stable type, for example changing:

struct Vec<T> {}

To:

struct Vec<T, A: Alloc = Global> {}

We would like to experiment with this change on Rust Nightly before it affects users one the Stable channel. That is, we would like to keep the type parameter unstable. Ideally, even the existence of this type parameter should not affect the stable channel at all.

As far as I understand this is not possible today. Ways forward include:

  • Extend the stability mechanism in the language to support unstable type parameters. This itself would likely take significant time to design and implement.

  • Accept that the existence of the new type parameter is instantly stable as soon as it lands, and hope that the trait that constraints this parameter being unstable is enough to avoid locking is into some API detail that we might want to change later. In this case Compat of adding parameters to stable types #1 needs to be resolved before adding the parameter.

  • Avoid adding type parameters at all to stable types. Define new types instead. This would mean that e.g. &mut NewVec<T, Global> could not be passed where &mut Vec<T> is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-CompatibilityIssues regarding semver compatibilityBlockerThis issue has to be resolved before progress can be made

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions