Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Mar 11, 2013

This is the first in a series of patches I'm working on to clean up the code related to deriving. This patch allows

#[deriving_eq]
#[deriving_iter_bytes]
#[deriving_clone]
struct Foo { bar: uint }

to be replaced with:

#[deriving(Eq, IterBytes, Clone)]
struct Foo { bar: uint }

It leaves the old attributes alone for the time being.

Eventually I'd like to incorporate the new closest-match-suggestion infrastructure for mistyped trait names, and also pass the sub-attributes to the deriving code, so that the following will be possible:

#[deriving(TotalOrd(qux, bar))]
struct Foo { bar: uint, baz: char, qux: int }

This says to derive an impl in which the objects' qux fields are compared first, followed by bar, while baz is ignored in the comparison. If no fields are specified explicitly, all fields will be compared in the order they're defined in the struct. This might also be useful for Eq. Coming soon.

@ghost
Copy link
Author

ghost commented Mar 11, 2013

Actually, I just realized that two of the spans are wrong for reporting the warning and the second error. Can I just add the fix commit to this pull request?

@thestinger
Copy link
Contributor

@apasel422: You can another commit, or you could rebase the existing ones - github just ties a pull request to a branch.

@ghost
Copy link
Author

ghost commented Mar 11, 2013

@thestinger: Thanks. I was just wondering if it would affect bors. I'll rebase shortly.

@ghost
Copy link
Author

ghost commented Mar 11, 2013

The span issue should be fixed now, and the patch has been squashed into a single commit.

@ghost
Copy link
Author

ghost commented Mar 12, 2013

I assume the two failures are related to why run-pass/deriving-via-extension-iter-bytes-enum.rs and run-pass/deriving-via-extension-iter-bytes-struct.rs are marked xfail-fast. I've done the same to my two tests and rebased again.

@ghost
Copy link
Author

ghost commented Mar 12, 2013

The failing test is now marked xfail-pretty. Hopefully the third time's the charm.

bors added a commit that referenced this pull request Mar 12, 2013
This is the first in a series of patches I'm working on to clean up the code related to `deriving`. This patch allows

```
#[deriving_eq]
#[deriving_iter_bytes]
#[deriving_clone]
struct Foo { bar: uint }
```
to be replaced with:
```
#[deriving(Eq, IterBytes, Clone)]
struct Foo { bar: uint }
```
It leaves the old attributes alone for the time being.

Eventually I'd like to incorporate the new closest-match-suggestion infrastructure for mistyped trait names, and also pass the sub-attributes to the deriving code, so that the following will be possible:
```
#[deriving(TotalOrd(qux, bar))]
struct Foo { bar: uint, baz: char, qux: int }
```
This says to derive an `impl` in which the objects' `qux` fields are compared first, followed by `bar`, while `baz` is ignored in the comparison. If no fields are specified explicitly, all fields will be compared in the order they're defined in the `struct`. This might also be useful for `Eq`. Coming soon.
@bors bors closed this Mar 12, 2013
@bors bors merged commit 24efea7 into rust-lang:incoming Mar 12, 2013
@ghost ghost deleted the metaderive branch March 12, 2013 18:16
calebcartwright pushed a commit to calebcartwright/rust that referenced this pull request Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants