Skip to content

Commit 0d644ca

Browse files
conr2dgui1117
andauthored
Replace derivative dependency with derive-where (#7324)
# Description Close #7122. This PR replaces the unmaintained `derivative` dependency with `derive-where`. ## Integration This PR doesn't change the public interfaces. ## Review Notes The `derivative` crate, previously used to derive basic traits for structs with generics or enums, is no longer actively maintained. It has been replaced with the `derive-where` crate, which offers a more straightforward syntax while providing the same features as `derivative`. --------- Co-authored-by: Guillaume Thiolliere <[email protected]>
1 parent 80e30ec commit 0d644ca

File tree

10 files changed

+44
-59
lines changed

10 files changed

+44
-59
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ cumulus-test-relay-sproof-builder = { path = "cumulus/test/relay-sproof-builder"
740740
cumulus-test-runtime = { path = "cumulus/test/runtime" }
741741
cumulus-test-service = { path = "cumulus/test/service" }
742742
curve25519-dalek = { version = "4.1.3" }
743-
derivative = { version = "2.2.0", default-features = false }
744743
derive-syn-parse = { version = "0.2.0" }
744+
derive-where = { version = "1.2.7" }
745745
derive_more = { version = "0.99.17", default-features = false }
746746
digest = { version = "0.10.3", default-features = false }
747747
directories = { version = "5.0.1" }

cumulus/pallets/weight-reclaim/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ frame-system = { workspace = true }
2727

2828
# Other dependencies
2929
codec = { features = ["derive"], workspace = true }
30-
derivative = { features = ["use_core"], workspace = true }
30+
derive-where = { workspace = true }
3131
docify = { workspace = true }
3232
log = { workspace = true, default-features = true }
3333
scale-info = { features = ["derive"], workspace = true }

cumulus/pallets/weight-reclaim/src/lib.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern crate alloc;
2929
use alloc::vec::Vec;
3030
use codec::{Decode, Encode};
3131
use cumulus_primitives_storage_weight_reclaim::get_proof_size;
32-
use derivative::Derivative;
32+
use derive_where::derive_where;
3333
use frame_support::{
3434
dispatch::{DispatchInfo, PostDispatchInfo},
3535
pallet_prelude::Weight,
@@ -83,13 +83,8 @@ pub mod pallet {
8383
/// calculates the unused weight using the post information and reclaim the unused weight.
8484
/// So this extension can be used as a drop-in replacement for `WeightReclaim` extension for
8585
/// parachains.
86-
#[derive(Encode, Decode, TypeInfo, Derivative)]
87-
#[derivative(
88-
Clone(bound = "S: Clone"),
89-
Eq(bound = "S: Eq"),
90-
PartialEq(bound = "S: PartialEq"),
91-
Default(bound = "S: Default")
92-
)]
86+
#[derive(Encode, Decode, TypeInfo)]
87+
#[derive_where(Clone, Eq, PartialEq, Default; S)]
9388
#[scale_info(skip_type_params(T))]
9489
pub struct StorageWeightReclaim<T, S>(pub S, core::marker::PhantomData<T>);
9590

polkadot/xcm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ workspace = true
1515
array-bytes = { workspace = true, default-features = true }
1616
bounded-collections = { features = ["serde"], workspace = true }
1717
codec = { features = ["derive", "max-encoded-len"], workspace = true }
18-
derivative = { features = ["use_core"], workspace = true }
18+
derive-where = { workspace = true }
1919
environmental = { workspace = true }
2020
frame-support = { workspace = true }
2121
hex-literal = { workspace = true, default-features = true }

polkadot/xcm/src/lib.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
extern crate alloc;
2626

2727
use codec::{Decode, DecodeLimit, Encode, Error as CodecError, Input, MaxEncodedLen};
28-
use derivative::Derivative;
28+
use derive_where::derive_where;
2929
use frame_support::dispatch::GetDispatchInfo;
3030
use scale_info::TypeInfo;
3131

@@ -88,13 +88,7 @@ macro_rules! versioned_type {
8888
$(#[$index5:meta])+
8989
V5($v5:ty),
9090
}) => {
91-
#[derive(Derivative, Encode, Decode, TypeInfo)]
92-
#[derivative(
93-
Clone(bound = ""),
94-
Eq(bound = ""),
95-
PartialEq(bound = ""),
96-
Debug(bound = "")
97-
)]
91+
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)]
9892
#[codec(encode_bound())]
9993
#[codec(decode_bound())]
10094
#[scale_info(replace_segment("staging_xcm", "xcm"))]
@@ -311,8 +305,8 @@ versioned_type! {
311305
}
312306

313307
/// A single XCM message, together with its version code.
314-
#[derive(Derivative, Encode, Decode, TypeInfo)]
315-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
308+
#[derive(Encode, Decode, TypeInfo)]
309+
#[derive_where(Clone, Eq, PartialEq, Debug)]
316310
#[codec(encode_bound())]
317311
#[codec(decode_bound())]
318312
#[scale_info(bounds(), skip_type_params(RuntimeCall))]

polkadot/xcm/src/v3/mod.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use codec::{
2828
MaxEncodedLen,
2929
};
3030
use core::{fmt::Debug, result};
31-
use derivative::Derivative;
31+
use derive_where::derive_where;
3232
use scale_info::TypeInfo;
3333

3434
mod junction;
@@ -57,8 +57,8 @@ pub const VERSION: super::Version = 3;
5757
/// An identifier for a query.
5858
pub type QueryId = u64;
5959

60-
#[derive(Derivative, Default, Encode, TypeInfo)]
61-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
60+
#[derive(Default, Encode, TypeInfo)]
61+
#[derive_where(Clone, Eq, PartialEq, Debug)]
6262
#[codec(encode_bound())]
6363
#[scale_info(bounds(), skip_type_params(Call))]
6464
#[scale_info(replace_segment("staging_xcm", "xcm"))]
@@ -474,15 +474,8 @@ impl XcmContext {
474474
///
475475
/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the
476476
/// outer XCM format, known as `VersionedXcm`.
477-
#[derive(
478-
Derivative,
479-
Encode,
480-
Decode,
481-
TypeInfo,
482-
xcm_procedural::XcmWeightInfoTrait,
483-
xcm_procedural::Builder,
484-
)]
485-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
477+
#[derive(Encode, Decode, TypeInfo, xcm_procedural::XcmWeightInfoTrait, xcm_procedural::Builder)]
478+
#[derive_where(Clone, Eq, PartialEq, Debug)]
486479
#[codec(encode_bound())]
487480
#[codec(decode_bound())]
488481
#[scale_info(bounds(), skip_type_params(Call))]

polkadot/xcm/src/v4/mod.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use codec::{
3535
MaxEncodedLen,
3636
};
3737
use core::{fmt::Debug, result};
38-
use derivative::Derivative;
38+
use derive_where::derive_where;
3939
use frame_support::dispatch::GetDispatchInfo;
4040
use scale_info::TypeInfo;
4141

@@ -65,8 +65,8 @@ pub const VERSION: super::Version = 4;
6565
/// An identifier for a query.
6666
pub type QueryId = u64;
6767

68-
#[derive(Derivative, Default, Encode, TypeInfo)]
69-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
68+
#[derive(Default, Encode, TypeInfo)]
69+
#[derive_where(Clone, Eq, PartialEq, Debug)]
7070
#[codec(encode_bound())]
7171
#[codec(decode_bound())]
7272
#[scale_info(bounds(), skip_type_params(Call))]
@@ -436,15 +436,8 @@ impl XcmContext {
436436
///
437437
/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the
438438
/// outer XCM format, known as `VersionedXcm`.
439-
#[derive(
440-
Derivative,
441-
Encode,
442-
Decode,
443-
TypeInfo,
444-
xcm_procedural::XcmWeightInfoTrait,
445-
xcm_procedural::Builder,
446-
)]
447-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
439+
#[derive(Encode, Decode, TypeInfo, xcm_procedural::XcmWeightInfoTrait, xcm_procedural::Builder)]
440+
#[derive_where(Clone, Eq, PartialEq, Debug)]
448441
#[codec(encode_bound())]
449442
#[codec(decode_bound())]
450443
#[scale_info(bounds(), skip_type_params(Call))]

polkadot/xcm/src/v5/mod.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use codec::{
2929
MaxEncodedLen,
3030
};
3131
use core::{fmt::Debug, result};
32-
use derivative::Derivative;
32+
use derive_where::derive_where;
3333
use scale_info::TypeInfo;
3434

3535
mod asset;
@@ -59,8 +59,8 @@ pub const VERSION: super::Version = 5;
5959
/// An identifier for a query.
6060
pub type QueryId = u64;
6161

62-
#[derive(Derivative, Default, Encode, TypeInfo)]
63-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
62+
#[derive(Default, Encode, TypeInfo)]
63+
#[derive_where(Clone, Eq, PartialEq, Debug)]
6464
#[codec(encode_bound())]
6565
#[codec(decode_bound())]
6666
#[scale_info(bounds(), skip_type_params(Call))]
@@ -378,15 +378,8 @@ impl XcmContext {
378378
///
379379
/// This is the inner XCM format and is version-sensitive. Messages are typically passed using the
380380
/// outer XCM format, known as `VersionedXcm`.
381-
#[derive(
382-
Derivative,
383-
Encode,
384-
Decode,
385-
TypeInfo,
386-
xcm_procedural::XcmWeightInfoTrait,
387-
xcm_procedural::Builder,
388-
)]
389-
#[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))]
381+
#[derive(Encode, Decode, TypeInfo, xcm_procedural::XcmWeightInfoTrait, xcm_procedural::Builder)]
382+
#[derive_where(Clone, Eq, PartialEq, Debug)]
390383
#[codec(encode_bound())]
391384
#[codec(decode_bound())]
392385
#[scale_info(bounds(), skip_type_params(Call))]

prdoc/pr_7324.prdoc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
title: Replace derivative dependency with derive-where
2+
author: conr2d
3+
topic: runtime
4+
5+
doc:
6+
- audience: Runtime Dev
7+
description: |-
8+
The `derivative` crate, previously used to derive basic traits for structs with
9+
generics or enums, is no longer actively maintained. It has been replaced with
10+
the `derive-where` crate, which offers a more straightforward syntax while
11+
providing the same features as `derivative`.
12+
13+
crates:
14+
- name: cumulus-pallet-weight-reclaim
15+
bump: patch
16+
- name: staging-xcm
17+
bump: patch

0 commit comments

Comments
 (0)