Skip to content

RFC: remove virtual structs - #341

Merged
brson merged 1 commit into
rust-lang:masterfrom
aturon:remove-virtual-structs
Oct 7, 2014
Merged

RFC: remove virtual structs#341
brson merged 1 commit into
rust-lang:masterfrom
aturon:remove-virtual-structs

Conversation

@aturon

Copy link
Copy Markdown
Contributor

Summary

Removes the "virtual struct" (aka struct inheritance) feature, which is currently feature gated.

Motivation

Virtual structs were added experimentally prior to the RFC process as a way of inheriting fields from one struct when defining a new struct.

The feature was introduced and remains behind a feature gate.

The motivations for removing this feature altogether are:

  1. The feature is likely to be replaced by a more general mechanism, as part of the need to address hierarchies such as the DOM, ASTs, and so on. See this post for some recent discussion.
  2. The implementation is somewhat buggy and incomplete, and the feature is not well-documented.
  3. Although it's behind a feature gate, keeping the feature around is still a maintenance burden.

Detailed design

Remove the implementation and feature gate for virtual structs.

Retain the virtual keyword as reserved for possible future use.

Drawbacks

The language will no longer offer any built-in mechanism for avoiding repetition of struct fields. Macros offer a reasonable workaround until a more general mechanism is added.

Unresolved questions

None known.

@sfackler

Copy link
Copy Markdown
Member

As one data point, there are no uses of virtual struct anywhere on Github except for the tests within rust-lang/rust itself: https://github.com/search?l=rust&q=%22virtual+struct%22&type=Code&utf8=%E2%9C%93

@nrc

nrc commented Sep 30, 2014

Copy link
Copy Markdown
Member

+1. We should keep virtual as a reserved keyword though (I think this is the only use of virtual at the moment).

@sinistersnare

Copy link
Copy Markdown

isn't struct inheritance hidden behind an feature gate? If so, why does it require a RFC to be removed? thats the point of feature gates. they may be removed at any time....

@aturon

Copy link
Copy Markdown
ContributorAuthor

@sinistersnare A few months ago we made a change in policy to require RFCs when removing any language features, even if feature-gated.

See this policy.

In general, we want to go through the formal feedback and decision process to change the direction on major features, whether adding or removing them.

@reem

reem commented Oct 1, 2014

Copy link
Copy Markdown

+1. This seems like a generally unused feature that will probably be made unneeded by one of the many inheritance proposals.

@brson
brson merged commit fa68ec1 into rust-lang:masterOct 7, 2014
@brson

brson commented Oct 7, 2014

Copy link
Copy Markdown
Contributor

Merged as RFC 71. Discussion. Tracking.

@chriskrychochriskrycho mentioned this pull request Mar 11, 2017
48 tasks
@CentrilCentril added A-data-types RFCs about data-types A-typesystem Type system related proposals & ideas A-product-types Product type related proposals A-stability Proposals relating to policy and changes about stability of features. labels Nov 23, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-data-typesRFCs about data-typesA-product-typesProduct type related proposalsA-stabilityProposals relating to policy and changes about stability of features.A-typesystemType system related proposals & ideas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@aturon@sfackler@nrc@sinistersnare@reem@brson@Centril