Skip to content

Attribute proc-macro follow up #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Support [`ZeroizeOnDrop`](https://docs.rs/zeroize/1.5.0/zeroize/trait.ZeroizeOnDrop.html).

### Changed
- **Breaking Change**: Changed to attribute instead of derive proc macro.

### Removed
- **Breaking Change**: Remove support for `Zeroize(drop)`.

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ This will generate trait implementations for `Example` for any `T`,
as opposed to std's derives, which would only implement these traits with
`T: Trait` bound to the corresponding trait.

Multiple `derive_where` attributes can be added to an item, but only the
first one must use any path qualifications.

```rust
#[derive_where::derive_where(Clone)]
#[derive_where(Debug)]
struct Example1<T>(PhantomData<T>);
```

In addition, the following convenience options are available:

### Generic type bounds
Expand Down
6 changes: 6 additions & 0 deletions non-msrv-tests/tests/ui/non_item.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use derive_where::derive_where;

#[derive_where(Clone)]
const _: () = ();

fn main() {}
5 changes: 5 additions & 0 deletions non-msrv-tests/tests/ui/non_item.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: expected one of: `struct`, `enum`, `union`
--> tests/ui/non_item.rs:4:1
|
4 | const _: () = ();
| ^^^^^
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
//! as opposed to std's derives, which would only implement these traits with
//! `T: Trait` bound to the corresponding trait.
//!
//! Multiple `derive_where` attributes can be added to an item, but only the
//! first one must use any path qualifications.
//!
//! ```
//! # use std::marker::PhantomData;
//! #[derive_where::derive_where(Clone)]
//! #[derive_where(Debug)]
//! struct Example1<T>(PhantomData<T>);
//! ```
//!
//! In addition, the following convenience options are available:
//!
//! ## Generic type bounds
Expand Down