Skip to content

Commit c00faa0

Browse files
committed
Merge rust-bitcoin#3176: Io improvements
56b19d0 Add missing IO impls for `std` types (Martin Habovstiak) 5e30c9f Use macro to implement our traits for `std` types (Martin Habovstiak) 505ecd8 Move `std` impl from `lib.rs` to `bridge.rs` (Martin Habovstiak) 94768d3 Add `set_position` method to `Cursor` (Martin Habovstiak) fc7e213 Add `bitcoin-io` -> `std` bridge (Martin Habovstiak) 54fdcb7 Add `std` -> `bitcoin-io` bridge (Martin Habovstiak) Pull request description: This addresses significant API holes. Originally I wanted to add a commit that bumps the IO version but then I remembered we have rust-bitcoin#3162 which we most likely also want to merge and release. Closes rust-bitcoin#3174 Closes rust-bitcoin#3175 ACKs for top commit: apoelstra: ACK 56b19d0 successfully ran local tests tcharding: ACK 56b19d0 Tree-SHA512: 9b0934da8dfd962c916c74032d734583175c6016f514861e24a29179c15925389a506ccf1b784a1bf99bc22909b5e7dcaece5fb689bd32f21ca0112ee798eca5
2 parents bcbb0ae + 56b19d0 commit c00faa0

File tree

4 files changed

+618
-36
lines changed

4 files changed

+618
-36
lines changed

io/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ all-features = true
2323
rustdoc-args = ["--cfg", "docsrs"]
2424

2525
[lints.rust]
26-
unexpected_cfgs = { level = "deny" }
26+
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(rust_v_1_72)', 'cfg(rust_v_1_73)', 'cfg(rust_v_1_75)', 'cfg(rust_v_1_78)'] }

io/build.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
fn main() {
2+
let rustc = std::env::var_os("RUSTC");
3+
let rustc = rustc.as_ref().map(std::path::Path::new).unwrap_or_else(|| "rustc".as_ref());
4+
let output = std::process::Command::new(rustc)
5+
.arg("--version")
6+
.output()
7+
.unwrap_or_else(|error| panic!("failed to run `{:?} --version`: {:?}", rustc, error));
8+
assert!(output.status.success(), "{:?} -- version returned non-zero exit code", rustc);
9+
let stdout = String::from_utf8(output.stdout).expect("rustc produced non-UTF-8 output");
10+
let version_prefix = "rustc ";
11+
if !stdout.starts_with(version_prefix) {
12+
panic!("unexpected rustc output: {}", stdout);
13+
}
14+
15+
let version = &stdout[version_prefix.len()..];
16+
let end = version.find(&[' ', '-'] as &[_]).unwrap_or(version.len());
17+
let version = &version[..end];
18+
let mut version_components = version.split('.');
19+
let major = version_components.next().unwrap();
20+
assert_eq!(major, "1", "unexpected Rust major version");
21+
let minor = version_components
22+
.next()
23+
.unwrap_or("0")
24+
.parse::<u64>()
25+
.expect("invalid Rust minor version");
26+
27+
let msrv = std::env::var("CARGO_PKG_RUST_VERSION").unwrap();
28+
let mut msrv = msrv.split(".");
29+
let msrv_major = msrv.next().unwrap();
30+
assert_eq!(msrv_major, "1", "unexpected Rust major version");
31+
let msrv_minor = msrv.next().unwrap().parse::<u64>().unwrap();
32+
33+
// print cfg for all interesting versions less than or equal to minor
34+
for version in msrv_minor..=minor {
35+
println!("cargo:rustc-cfg=rust_v_1_{}", version);
36+
}
37+
}

0 commit comments

Comments
 (0)