Skip to content

Commit 6c61e10

Browse files
committed
Fix pinning (schemars and MSRV)
Done as is single patch to make sure all the docs and CI are in sync and correct. We currently pin the `schemars` dependency using `<=0.8.3` as well as a the `dyn-clone` transient dependency in the manifest (`hashes` and the extended test crate). This is incorrect because it makes usage of the crate klunky (or possibly impossible) if downstream users wish to use a later version of `schemars`. Observe also that we do not have to pin `schemars`, we do however have to pin the `serde` crate if either `serde` or `schemars` features are enabled. Do so in CI and document in the readme file within hashes. Currently we have a pin remaining from the old MSRV (`syn` due to use of `matches!`). Fix pinning by: - Remove pin in manifest for `schemars` - Fix pinning for MSRV in CI and docs (this includes documenting pinning requirements for `schemars` feature because it is related to the other pin of `serde`) in both `hashes` readme and main repo readme.
1 parent c8e38d6 commit 6c61e10

File tree

8 files changed

+44
-15
lines changed

8 files changed

+44
-15
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ For more information please see `./CONTRIBUTING.md`.
7777

7878
This library should always compile with any combination of features on **Rust 1.48.0**.
7979

80-
To build with the MSRV you will need to pin some dependencies:
80+
To build with the MSRV you will need to pin `serde` (if you have the feature enabled)
81+
8182
```
83+
# serde 1.0.157 uses syn 2.0 which requires edition 2021
8284
cargo update -p serde --precise 1.0.156
83-
cargo update -p syn --precise 1.0.107
8485
```
8586

87+
before building. (And if your code is a library, your downstream users will need to run these
88+
commands, and so on.)
89+
8690
## Installing Rust
8791

8892
Rust can be installed using your package manager of choice or

bitcoin/contrib/test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ fi
2727
if cargo --version | grep "1\.48"; then
2828
# 1.0.157 uses syn 2.0 which requires edition 2018
2929
cargo update -p serde --precise 1.0.156
30-
# 1.0.108 uses `matches!` macro so does not work with Rust 1.41.1, bad `syn` no biscuit.
31-
cargo update -p syn --precise 1.0.107
3230
fi
3331

3432
# We should not have any duplicate dependencies. This catches mistakes made upgrading dependencies

hashes/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ exclude = ["tests", "contrib"]
1616
default = ["std"]
1717
std = ["alloc", "internals/std"]
1818
alloc = ["internals/alloc"]
19-
schemars = ["actual-schemars", "dyn-clone"]
2019
serde-std = ["serde/std"]
2120

2221
[package.metadata.docs.rs]
@@ -27,13 +26,9 @@ rustdoc-args = ["--cfg", "docsrs"]
2726
internals = { path = "../internals", package = "bitcoin-private", version = "0.1.0" }
2827

2928
core2 = { version = "0.3.0", default_features = false, optional = true }
29+
schemars = { version = "0.8.3", optional = true }
3030
# Only enable this if you explicitly do not want to use "std", otherwise enable "serde-std".
3131
serde = { version = "1.0", default-features = false, optional = true }
32-
# Do NOT use this as a feature! Use the `schemars` feature instead. Can only be used with "std" enabled.
33-
actual-schemars = { package = "schemars", version = "<=0.8.3", optional = true }
34-
# Do NOT enable this dependency, this is just to pin dyn-clone (transitive dep from schemars)
35-
# because 1.0.8 does not build with Rust 1.41.1 (because of useage of `Arc::as_ptr`).
36-
dyn-clone = { version = "<=1.0.7", default_features = false, optional = true }
3732

3833
[dev-dependencies]
3934
serde_test = "1.0"

hashes/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ since these are needed to display hashes anway.
1313

1414
This library should always compile with any combination of features on **Rust 1.48.0**.
1515

16+
17+
To build with the MSRV you will need to pin `serde` (if you have either the `serde` or the
18+
`schemars` feature enabled)
19+
20+
```
21+
# serde 1.0.157 uses syn 2.0 which requires edition 2021
22+
cargo update -p serde --precise 1.0.156
23+
```
24+
25+
before building. (And if your code is a library, your downstream users will need to run these
26+
commands, and so on.)
27+
1628
## Contributions
1729

1830
Contributions are welcome, including additional hash function implementations.

hashes/contrib/test.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
set -ex
44

@@ -17,6 +17,12 @@ if cargo --version | grep nightly >/dev/null; then
1717
NIGHTLY=true
1818
fi
1919

20+
# Pin dependencies as required if we are using MSRV toolchain.
21+
if cargo --version | grep "1\.48"; then
22+
# 1.0.157 uses syn 2.0 which requires edition 2021
23+
cargo update -p serde --precise 1.0.156
24+
fi
25+
2026
# Make all cargo invocations verbose
2127
export CARGO_TERM_VERBOSE=true
2228

@@ -52,8 +58,12 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
5258
cargo test --no-default-features --features="std,schemars"
5359
fi
5460

61+
REPO_DIR=$(git rev-parse --show-toplevel)
62+
5563
if [ "$DO_SCHEMARS_TESTS" = true ]; then
56-
(cd extended_tests/schemars && cargo test)
64+
pushd "$REPO_DIR/hashes/extended_tests/schemars" > /dev/null
65+
cargo test
66+
popd > /dev/null
5767
fi
5868

5969
# Build the docs if told to (this only works with the nightly toolchain)

hashes/extended_tests/schemars/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ path = "../.."
1313
features = ['schemars', 'serde']
1414

1515
[dependencies]
16-
jsonschema-valid = "^0.4.0"
16+
jsonschema-valid = "0.4.0"
1717
serde = { version = "1.0", default-features = false}
18-
schemars = { version = "<=0.8.3"}
18+
schemars = "0.8.3"
1919
serde_test = "1.0"
2020
serde_json = "1.0"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Test crate for the schemars feature
2+
3+
Run as usual with `cargo test`.
4+
5+
## Minimum Supported Rust Version (MSRV)
6+
7+
To run the tests with the MSRV you will need to pin some dependencies:
8+
9+
- `cargo update -p serde --precise 1.0.156`
10+
- `cargo update -p syn --precise 1.0.107`

hashes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub mod _export {
113113
}
114114

115115
#[cfg(feature = "schemars")]
116-
extern crate actual_schemars as schemars;
116+
extern crate schemars;
117117

118118
mod internal_macros;
119119
#[macro_use]

0 commit comments

Comments
 (0)