Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- ## [Unreleased] -->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I doing the right thing here? Or should I leave something specific in place that cargo-release requires?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that is exactly what I use for it 👍 (though at some point I should probably adjust the regex to be less whitespace sensitive :D

## [Unreleased]

### Changed
- `#[serde(...)]` attributes are now allowed even when not deriving
`De/Serialize` with `#[derive_where(...)]`.

## [1.5.0] - 2025-06-08

### Added
Expand Down
12 changes: 0 additions & 12 deletions src/attr/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,6 @@ impl ItemAttr {
return Err(Error::none(span));
}

// Check for `#[serde(...)]` attributes without `De/Serialize`.
#[cfg(feature = "serde")]
if !self_.derive_wheres.iter().any(|derive_where| {
derive_where.contains(Trait::Deserialize) | derive_where.contains(Trait::Serialize)
}) {
for attr in attrs {
if attr.path().is_ident("serde") {
return Err(Error::serde_without_serde(attr.span()));
}
}
}

// Merge `DeriveWhere`s with the same bounds.
self_
.derive_wheres
Expand Down
6 changes: 0 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,6 @@ impl Error {
syn::Error::new(skip_clone, "Cannot skip `Clone` while deriving `Copy`")
}

/// Unsupported `serde(...)` without deriving `De/Serialize`.
#[cfg(feature = "serde")]
pub fn serde_without_serde(serde: Span) -> syn::Error {
syn::Error::new(serde, "Found unused `#[serde(...)]`")
}

/// Conflicting `serde(bound ...)` when deriving `De/Serialize`.
#[cfg(feature = "serde")]
pub fn serde_bound(serde: Span) -> syn::Error {
Expand Down
4 changes: 0 additions & 4 deletions tests/ui/serde/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ use std::marker::PhantomData;

use derive_where::derive_where;

#[derive_where(Clone)]
#[serde(crate = "serde_")]
struct InvalidSerde<T>(PhantomData<T>);

#[derive_where(Deserialize)]
#[serde(bound = "")]
struct ConflictingBound<T>(PhantomData<T>);
Expand Down
14 changes: 4 additions & 10 deletions tests/ui/serde/serde.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
error: Found unused `#[serde(...)]`
--> tests/ui/serde/serde.rs:6:1
|
6 | #[serde(crate = "serde_")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Found conflicting `#[serde(bound ...)]`
--> tests/ui/serde/serde.rs:10:9
|
10 | #[serde(bound = "")]
| ^^^^^^^^^^
--> tests/ui/serde/serde.rs:6:9
|
6 | #[serde(bound = "")]
| ^^^^^^^^^^