Skip to content
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
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
2 changes: 1 addition & 1 deletion tests/ui/serde/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use derive_where::derive_where;

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

#[derive_where(Deserialize)]
#[serde(bound = "")]
Expand Down
6 changes: 0 additions & 6 deletions tests/ui/serde/serde.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
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
|
Expand Down