Skip to content

Deriving may want to ignore marker fields #14268

Closed
@lilyball

Description

@lilyball

Marker fields are used to provide extra information about types, including opting out of Copy, Send, and Share bounds. However, the presence of a marker field can prevent the ability to #[derive] traits for that type. For example, core::kinds::marker::NoCopy only implements Clone and Eq (according to rustdoc; I am unsure if there are any libstd traits it implements because rustdoc doesn't show cross-crate traits). This means that any struct with a NoCopy field cannot e.g. derive Show, or Ord, or other useful traits.

I think the right solution here is to simply not consider the marker fields when deriving traits, with the only exception being Clone. Every other trait should just pretend that field doesn't exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions