Skip to content

inherit stable annotations in enum variants and field items #370

Closed
@nikomatsakis

Description

@nikomatsakis
Contributor

Proposal

Some time back, @estebank opened rust-lang/rust#71481 which proposed to fix rust-lang/rust#65515 by allowing stability attributes to be 'inherited'. The idea is that if you declare a struct/enum to be stable, then you are also declaring (by default) all of its public fields to be stable.

The primary motivation for the change is diagnostics. In our error messages, we sometimes print type declarations by excerpting from the source, and those currently contain various stability attributes that distract the user.

This change also reduces the annotation burden. As @estebank argues in #65515, it is quite unusual to have a stable struct/enum with public fields that are unstable (although I've not tried to verify this by inspection). In #65515, @alexcrichton commented:

I think we've never had a case for public enums and private variants [..] so removing all the internal attributes should be fine.

@dtolnay commented, and @SimonSapin concurred:

Removing #[stable] from public enum variants and their fields both seem good to me. This isn't something we would need right away but what would make sense to me is if public elements of an item (its variants and fields) inherit #[stable] from the item, with explicit #[unstable] to negate that behavior.

The main downside is that if we DO have a struct that is stabilized, but we do not wish to stabilize its public fields, we have to remember to explicitly annotate those fields as UNSTABLE, as @nagisa pointed out.

Based on the above comments I believe the change makes sense, both for error messages and to reduce annotation burden.

Mentors or Reviewers

@estebank has already prepared the PR

Process

The main points of the Major Change Process is as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Activity

added
T-compilerAdd this label so rfcbot knows to poll the compiler team
major-changeA proposal to make a major change to rustc
on Oct 14, 2020
rustbot

rustbot commented on Oct 14, 2020

@rustbot
Collaborator

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

nikomatsakis

nikomatsakis commented on Oct 14, 2020

@nikomatsakis
ContributorAuthor

@rustbot second

added
final-comment-periodThe FCP has started, most (if not all) team members are in agreement
on Oct 14, 2020
pnkfelix

pnkfelix commented on Oct 15, 2020

@pnkfelix
Member

Discussed at T-compiler meeting; we're going to put this through a full FCP process rather than the MCP seconding process.

@rfcbot fcp merge

rfcbot

rfcbot commented on Oct 15, 2020

@rfcbot
Collaborator

Team member @pnkfelix has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

added
disposition-mergeThe FCP starter wants to merge this
proposed-final-comment-periodAn FCP has been started, cast your votes and raise concerns
and removed
disposition-mergeThe FCP starter wants to merge this
final-comment-periodThe FCP has started, most (if not all) team members are in agreement
proposed-final-comment-periodAn FCP has been started, cast your votes and raise concerns
on Oct 15, 2020
nagisa

nagisa commented on Oct 24, 2020

@nagisa
Member

@rfcbot reviewed

I still think libstd is in a position where additional care regarding stability of its APIs warrants the annotation burden, but I don't have much reason to block this.

rfcbot

rfcbot commented on Oct 24, 2020

@rfcbot
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

added
final-comment-periodThe FCP has started, most (if not all) team members are in agreement
and removed
proposed-final-comment-periodAn FCP has been started, cast your votes and raise concerns
on Oct 24, 2020
added
finished-final-comment-periodThe FCP has finished, action upon the disposition label needs to be taken
and removed
final-comment-periodThe FCP has started, most (if not all) team members are in agreement
on Nov 3, 2020
rfcbot

rfcbot commented on Nov 3, 2020

@rfcbot
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

nikomatsakis

nikomatsakis commented on Nov 5, 2020

@nikomatsakis
ContributorAuthor

Closing as accepted. The PR is rust-lang/rust#71481

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

    T-compilerAdd this label so rfcbot knows to poll the compiler teamdisposition-mergeThe FCP starter wants to merge thisfinished-final-comment-periodThe FCP has finished, action upon the disposition label needs to be takenmajor-changeA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was accepted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @spastorino@nikomatsakis@pnkfelix@nagisa@rfcbot

        Issue actions

          inherit stable annotations in enum variants and field items · Issue #370 · rust-lang/compiler-team