# Add skip attribute to various derives

**URL:** <https://internals.rust-lang.org/t/add-skip-attribute-to-various-derives/17411>\
**Category:** libs\
**Created:** [September 20, 2022, 12:05am UTC](https://internals.rust-lang.org/t/add-skip-attribute-to-various-derives/17411 "2022-09-20T00:05:06Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![woshilapin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/woshilapin/32/7071_2.png) [@woshilapin](https://internals.rust-lang.org/u/woshilapin)\
**Post date:** [October 1, 2022, 8:09am UTC](https://internals.rust-lang.org/t/add-skip-attribute-to-various-derives/17411/21 "2022-10-01T08:09:31Z")

</div>

It seems relevant and has not been mentioned yet, the crate [`derivative`](https://crates.io/crates/derivative) does a good job of implementing some standard traits automatically with ignoring some fields.

---

<div class="post-metadata">

**Author:** ![dlight](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dlight/32/8462_2.png) [@dlight](https://internals.rust-lang.org/u/dlight)\
**Post date:** [October 2, 2022, 4:18am UTC](https://internals.rust-lang.org/t/add-skip-attribute-to-various-derives/17411/22 "2022-10-02T04:18:37Z")

</div>

> [@yoshuawuyts](#):
>
> It also doesn’t seem like it would conflict with [serde’s skip attributes](https://serde.rs/attr-skip-serializing.html) and could potentially even be made to compose with [`cfg_attr`](https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute).

I wish Rust's attributes were namespaced! Fortunately serde self-namespaces in a way, it's `#[serde(skip_serializing)]` so it's less likely to conflict with some other macro or custom derive, but I wish we had more mechanisms to ensure that attribute macros will compose

I mean, I can see `#[skip]` possibly conflicting with something else, as well as [the already stabilized `#[default]`](https://github.com/rust-lang/rust/pull/94457)

Rust should at least have a way to make an attribute visible only to a specific macro, something like `#[macro_attr(myattrmacro, skip)]` which makes `#[skip]` visible to `#[myattrmacro]`, like this:

```rust
#[derive(Ord)]
#[myattrmacro]
pub struct A {
     #[macro_attr(myattrmacro, skip)]
     something: B,
}

```

So that `#[myattrmacro]` sees

```rust
pub struct A {
     #[skip]
     something: B,
}

```

And `#[derive(Ord)]` sees

```rust
pub struct A {
     something: B,
}

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [December 31, 2022, 4:18am UTC](https://internals.rust-lang.org/t/add-skip-attribute-to-various-derives/17411/23 "2022-12-31T04:18:56Z")

</div>

Closed on December 31, 2022, 4:18am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

[Previous page](https://internals.rust-lang.org/t/add-skip-attribute-to-various-derives/17411.md?page=1)
