Skip to content

Commit b229be7

Browse files
authored
Merge pull request #240 from aldanor/feature/fixups-2023
2023 fixups
2 parents 5e5bedb + 22ec7b5 commit b229be7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+226
-212
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: actions-rs/cargo@v1
3636
with:
3737
command: ${{matrix.command}}
38-
args: "${{matrix.command == 'fmt' && '--all -- --check' || '--workspace --exclude hdf5-src -- -D warnings -D clippy::cargo'}}"
38+
args: "${{matrix.command == 'fmt' && '--all -- --check' || '--workspace --exclude hdf5-src -- -D warnings -D clippy::cargo -A clippy::multiple-crate-versions'}}"
3939

4040
doc: # This task should mirror the procedure on docs.rs
4141
runs-on: ubuntu-latest
@@ -58,8 +58,7 @@ jobs:
5858
include:
5959
- {version: [email protected]}
6060
- {version: [email protected]}
61-
- {version: [email protected]}
62-
- {version: hdf5-mpi, mpi: true}
61+
# - {version: hdf5-mpi, mpi: true} # TODO: re-enable once 1.14 support is merged in
6362
steps:
6463
- name: Checkout repository
6564
uses: actions/checkout@v2
@@ -156,13 +155,13 @@ jobs:
156155

157156
apt:
158157
name: apt
159-
runs-on: ubuntu-${{matrix.ubuntu}}
158+
runs-on: ubuntu-20.04
160159
strategy:
161160
fail-fast: false
162161
matrix:
163162
include:
164-
- {ubuntu: 18.04, mpi: mpich, rust: beta}
165-
- {ubuntu: 20.04, mpi: openmpi, rust: stable}
163+
- {mpi: mpich, rust: beta}
164+
- {mpi: openmpi, rust: stable}
166165
steps:
167166
- name: Checkout repository
168167
uses: actions/checkout@v2
@@ -236,7 +235,7 @@ jobs:
236235

237236
msrv:
238237
name: Minimal Supported Rust Version
239-
runs-on: ubuntu-18.04
238+
runs-on: ubuntu-20.04
240239
strategy:
241240
fail-fast: false
242241
steps:
@@ -245,25 +244,27 @@ jobs:
245244
with: {submodules: true}
246245
- name: Install Rust
247246
uses: actions-rs/toolchain@v1
248-
with: {toolchain: 1.54, profile: minimal, override: true}
247+
with: {toolchain: 1.64, profile: minimal, override: true}
249248
- name: Build and test all crates
250249
run:
251250
cargo test --workspace -vv --features=hdf5-sys/static --exclude=hdf5-derive
252251

253-
wine:
254-
name: wine
255-
runs-on: ubuntu-latest
256-
steps:
257-
- name: Checkout repository
258-
uses: actions/checkout@v2
259-
with: {submodules: true}
260-
- name: Install Rust
261-
uses: actions-rs/toolchain@v1
262-
with: {toolchain: stable, target: x86_64-pc-windows-gnu, profile: minimal, override: true}
263-
- name: Install dependencies
264-
run: sudo apt-get update && sudo apt install wine64 mingw-w64
265-
- name: Build and test
266-
run: env CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features hdf5-sys/static --target x86_64-pc-windows-gnu -- --skip test_compile_fail
252+
# # TODO: temporarily disabled until fixed (see https://github.com/aldanor/hdf5-rust/issues/241)
253+
# wine:
254+
# name: wine
255+
# runs-on: ubuntu-latest
256+
# steps:
257+
# - name: Checkout repository
258+
# uses: actions/checkout@v2
259+
# with: {submodules: true}
260+
# - name: Install Rust
261+
# uses: actions-rs/toolchain@v1
262+
# with: {toolchain: stable, target: x86_64-pc-windows-gnu, profile: minimal, override: true}
263+
# - name: Install dependencies
264+
# run: sudo apt-get update && sudo apt install wine64 mingw-w64
265+
# - name: Build and test
266+
# run: env CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine64 cargo test --features hdf5-sys/static --target x86_64-pc-windows-gnu -- --skip test_compile_fail
267+
267268
addr_san:
268269
name: Address sanitizer
269270
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
### Changed
1313

1414
- The `H5Type` derive macro now uses `proc-macro-error` to emit error messages.
15-
- MSRV is now `1.54` following a bump in a dependency.
15+
- MSRV is now `1.64.0` and Rust edition has now been bumped to 2021.
1616

1717
### Fixed
1818

@@ -21,6 +21,7 @@
2121
- Fixed a missing symbol when building `hdf5-src` with `libz-sys`.
2222
- Fixed a bug where errors were only silenced on the main thread.
2323
- Fixed a memory leak when opening datasets.
24+
- Avoid creating unaligned references in `H5Type` derive macro.
2425

2526
## 0.8.1
2627

Cargo.toml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,26 @@
1-
[package]
2-
name = "hdf5"
1+
[workspace]
2+
members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
3+
default-members = ["hdf5", "hdf5-types", "hdf5-derive", "hdf5-sys"]
4+
5+
[workspace.package]
36
version = "0.8.1" # !V
4-
authors = ["Ivan Smirnov <[email protected]>"]
7+
rust-version = "1.64.0"
8+
authors = ["Ivan Smirnov <[email protected]>", "Magnus Ulimoen <[email protected]>"]
59
keywords = ["hdf5"]
610
license = "MIT OR Apache-2.0"
7-
readme = "README.md"
8-
description = "Thread-safe Rust bindings for the HDF5 library."
911
repository = "https://github.com/aldanor/hdf5-rust"
1012
homepage = "https://github.com/aldanor/hdf5-rust"
11-
build = "build.rs"
12-
edition = "2018"
13-
categories = ["science", "filesystem"]
14-
15-
[features]
16-
default = []
17-
mpio = ["mpi-sys", "hdf5-sys/mpio"]
18-
lzf = ["lzf-sys", "errno"]
19-
blosc = ["blosc-sys"]
20-
# The features with version numbers such as 1.10.3, 1.12.0 are metafeatures
21-
# and is only available when the HDF5 library is at least this version.
22-
# Features have_direct and have_parallel are also metafeatures and dependent
23-
# on the HDF5 library which is linked against.
24-
25-
[workspace]
26-
members = [".", "hdf5-types", "hdf5-derive", "hdf5-sys", "hdf5-src"]
27-
default-members = [".", "hdf5-types", "hdf5-derive", "hdf5-sys"]
13+
edition = "2021"
2814

29-
[dependencies]
30-
bitflags = "1.2"
31-
lazy_static = "1.4"
32-
libc = "0.2"
33-
parking_lot = "0.11"
34-
ndarray = "0.15"
35-
paste = "1.0"
36-
mpi-sys = { version = "0.1", optional = true }
37-
errno = { version = "0.2", optional = true }
38-
hdf5-sys = { path = "hdf5-sys", version = "0.8.1" } # !V
39-
hdf5-types = { path = "hdf5-types", version = "0.8.1" } # !V
40-
hdf5-derive = { path = "hdf5-derive", version = "0.8.1" } # !V
41-
blosc-sys = { version = "0.1.1", package = "blosc-src", optional = true }
42-
lzf-sys = { version = "0.1", optional = true }
15+
[workspace.dependencies]
16+
# external
4317
cfg-if = "1.0"
44-
45-
[dev-dependencies]
46-
paste = "1.0"
47-
pretty_assertions = "1.0"
48-
rand = { version = "0.8", features = ["small_rng"] }
49-
regex = "1.3"
50-
scopeguard = "1.0"
51-
tempfile = "3.2"
52-
53-
[package.metadata.docs.rs]
54-
features = ["hdf5-sys/static", "hdf5-sys/zlib", "blosc", "lzf"]
55-
rustdoc-args = ["--cfg", "docsrs"]
18+
libc = "0.2"
19+
libz-sys = { version = "1.1", default-features = false }
20+
mpi-sys = "0.2"
21+
regex = "1.8"
22+
# internal
23+
hdf5-derive = { version = "0.8.1", path = "hdf5-derive" } # !V
24+
hdf5-src = { version = "0.8.1", path = "hdf5-src" } # !V
25+
hdf5-sys = { version = "0.8.1", path = "hdf5-sys" } # !V
26+
hdf5-types = { version = "0.8.1", path = "hdf5-types" } # !V

hdf5-derive/Cargo.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
[package]
22
name = "hdf5-derive"
3-
version = "0.8.1" # !V
4-
authors = ["Ivan Smirnov <[email protected]>"]
5-
keywords = ["hdf5"]
6-
license = "MIT OR Apache-2.0"
73
description = "Derive macro for HDF5 structs and enums."
8-
repository = "https://github.com/aldanor/hdf5-rust"
9-
homepage = "https://github.com/aldanor/hdf5-rust"
10-
edition = "2018"
11-
readme = "README.md"
124
categories = ["procedural-macro-helpers"]
5+
readme = "README.md"
6+
version.workspace = true
7+
rust-version.workspace = true
8+
authors.workspace = true
9+
keywords.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
12+
homepage.workspace = true
13+
edition.workspace = true
1314

1415
[lib]
1516
proc-macro = true
1617

1718
[dependencies]
18-
proc-macro-error = { version = "1.0.4", default-features = false }
19+
proc-macro-error = { version = "1.0", default-features = false }
1920
proc-macro2 = "1.0"
20-
quote = "^1.0.2"
21-
syn = { version = "^1.0.5", features = ["derive", "extra-traits"]}
21+
quote = "1.0"
22+
syn = { version = "2.0", features = ["derive", "extra-traits"]}
2223

2324
[dev-dependencies]
2425
trybuild = "1.0"
25-
hdf5 = { version = ">=0.7.1", path = ".." }
26+
hdf5 = { version = ">=0.7.1", path = "../hdf5" }

hdf5-derive/src/lib.rs

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use proc_macro2::{Ident, Span, TokenStream};
88
use proc_macro_error::{abort, proc_macro_error};
99
use quote::{quote, ToTokens};
1010
use syn::{
11-
parse_macro_input, AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, Lit, Meta,
12-
NestedMeta, Type, TypeGenerics, TypePath,
11+
parse_macro_input, AttrStyle, Attribute, Data, DeriveInput, Expr, Fields, Index, LitStr, Type,
12+
TypeGenerics, TypePath,
1313
};
1414

1515
#[proc_macro_derive(H5Type, attributes(hdf5))]
@@ -107,55 +107,40 @@ fn is_phantom_data(ty: &Type) -> bool {
107107
}
108108

109109
fn find_repr(attrs: &[Attribute], expected: &[&str]) -> Option<Ident> {
110+
let mut repr = None;
110111
for attr in attrs.iter() {
111112
if attr.style != AttrStyle::Outer {
112113
continue;
113114
}
114-
let list = match attr.parse_meta() {
115-
Ok(Meta::List(list)) => list,
116-
_ => continue,
117-
};
118-
if !list.path.get_ident().map_or(false, |ident| ident == "repr") {
115+
if !attr.path().is_ident("repr") {
119116
continue;
120117
}
121-
for item in list.nested.iter() {
122-
let path = match item {
123-
NestedMeta::Meta(Meta::Path(ref path)) => path,
124-
_ => continue,
125-
};
126-
let ident = match path.get_ident() {
127-
Some(ident) => ident,
128-
_ => continue,
129-
};
130-
if expected.iter().any(|&s| ident == s) {
131-
return Some(Ident::new(&ident.to_string(), Span::call_site()));
118+
attr.parse_nested_meta(|meta| {
119+
if expected.iter().any(|s| meta.path.is_ident(s)) {
120+
if repr.is_some() {
121+
abort!(meta.path, "ambiguous repr attribute");
122+
} else {
123+
repr = meta.path.get_ident().cloned();
124+
}
132125
}
133-
}
126+
Ok(())
127+
})
128+
.ok()?;
134129
}
135-
136-
None
130+
repr
137131
}
138132

139133
fn find_hdf5_rename(attrs: &[Attribute]) -> Option<String> {
140-
if let Some(attr) = attrs.iter().find(|a| a.path.is_ident("hdf5")) {
141-
if let Ok(Meta::List(meta_list)) = attr.parse_meta() {
142-
let rename_literal = meta_list.nested.iter().find_map(|n| {
143-
if let NestedMeta::Meta(Meta::NameValue(name_value)) = n {
144-
if name_value.path.is_ident("rename") {
145-
return Some(&name_value.lit);
146-
}
147-
}
148-
149-
None
150-
});
151-
152-
if let Some(Lit::Str(renamed)) = rename_literal {
153-
return Some(renamed.value());
154-
}
134+
let mut rename = None;
135+
let attr = attrs.iter().find(|a| a.path().is_ident("hdf5"))?;
136+
attr.parse_nested_meta(|meta| {
137+
if meta.path.is_ident("rename") && rename.is_none() {
138+
rename = Some(meta.value()?.parse::<LitStr>()?.value());
155139
}
156-
}
157-
158-
None
140+
Ok(())
141+
})
142+
.ok()?;
143+
rename
159144
}
160145

161146
fn pluck<'a, I, F, T, S>(iter: I, func: F) -> Vec<S>

hdf5-src/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
[package]
22
name = "hdf5-src"
3-
version = "0.8.1" # !V
4-
authors = ["Ivan Smirnov <[email protected]>"]
5-
keywords = ["hdf5"]
63
license-file = "ext/hdf5/COPYING"
74
build = "build.rs"
8-
repository = "https://github.com/aldanor/hdf5-rust"
9-
homepage = "https://github.com/aldanor/hdf5-rust"
105
description = "Build script for compiling HDF5 C library from source."
11-
edition = "2018"
126
links = "hdf5src"
137
readme = "README.md"
148
categories = ["ffi"]
@@ -26,6 +20,13 @@ exclude = [
2620
"ext/hdf5/hl/tools/**",
2721
"ext/hdf5/hl/examples/**",
2822
]
23+
version.workspace = true
24+
rust-version.workspace = true
25+
authors.workspace = true
26+
keywords.workspace = true
27+
repository.workspace = true
28+
homepage.workspace = true
29+
edition.workspace = true
2930

3031
[features]
3132
hl = []
@@ -34,7 +35,7 @@ deprecated = []
3435
threadsafe = []
3536

3637
[dependencies]
37-
libz-sys = { version = "1.0.25", features = ["static", "libc"], optional = true, default-features=false }
38+
libz-sys = { workspace = true, optional = true, features = ["static", "libc"] }
3839

3940
[build-dependencies]
40-
cmake = "0.1.44"
41+
cmake = "0.1"

0 commit comments

Comments
 (0)