rust-lang/project-const-traits

Add const stability tracking for traits

Closed this issue · 1 comments

I think we should add support for #[rustc_const_(un)stable] attributes on traits. That would set a feature gate which would be required to

  • use this trait in a ~const Trait or const Trait bound
  • write a const impl for that trait
  • call any function from this trait in const context

(All of these also require the const_trait_impl feature gate on top of the per-trait feature gate.)

Currently we have a #[const_trait] attribute; every trait in a staged-api crate that has that attribute should then also be required to have a const stability attribute.

For now, making such a trait rustc_const_stable should be forbidden since the feature is not ready yet. Or maybe we rely on the extra gating with the const_trait_impl feature for that? Once a trait is rustc_const_stable, all its const impl must also be marked rustc_const_stable.