Skip to content

Decide on (and implement) which parts of the AST can get stability attributes #8967

Closed

Description

@huonw

As of #8921, the compiler checks the attributes on structs, enum variants (not enums themselves) and functions. Definitely required: methods (#8961) and mods (#8962).

Up for discussion:

  • traits
  • enums
  • impls (both impl Type and impl Trait for Type)
  • struct fields
  • type aliases.
  • foreign fns
  • anything else that can take attributes in the ast

(Part of #6875.)

Activity

  1. brson commented on Sep 5, 2013

    @brson
    Contributor

    Anything that might be named should probably have stability levels. From your list the two that I see that might not need them are fields (stability can apply to the entire struct) and impls (methods may be enough).

    Traits are important and especially tricky though, since there are multiple ways for them to be used. It would be great if calling trait methods and implementing traits could be considered separately. As long as the trait has a stable name, and you don't implement the trait, then just calling a method doesn't require all methods on the trait to be stable. Hard to represent all that subtlety though. If we can't then basically you have to declare an entire trait stable at once, which will make stabilizing things like str and vec pretty tough - I can foresee traits like OwnedVector2, OwnedVector3 in our future.

  2. huonw commented on Sep 6, 2013

    @huonw
    ContributorAuthor

    I was assuming that trait methods would be checked (presumably only annotations on the original trait, otherwise it will act differently for generics and concrete types), and that it would be useful to mark trait impls, i.e. "don't use this trait on this type"; although, to be 100% useful, it would have to check whenever it was used in a context that assumed this trait (i.e. generics, casting to a trait object, calling a method) which might be tricky.

  3. emberian commented on Dec 30, 2013

    @emberian
    Contributor

    Traits and enums definitely, but I don't think the rest are going to be useful.

  4. steveklabnik commented on Jan 21, 2015

    @steveklabnik
    Contributor

    I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

    This issue has been moved to the RFCs repo: rust-lang/rfcs#687

  5. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions