Skip to content

Commit 0997504

Browse files
committed
Bump MSRV to 1.81.0
1 parent 5f7b56b commit 0997504

26 files changed

+252
-247
lines changed

Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT"
1010
version = "0.95.1"
1111
# bump edition to 2024 when MSRV is 1.85
1212
edition = "2021"
13-
rust-version = "1.77.0"
13+
rust-version = "1.81.0"
1414
authors = ["Pro <[email protected]>", "Mathieu Poumeyrol <[email protected]>"]
1515
exclude = ["/.github", "/ci", "/tools", "/.editorconfig", "/.gitattributes", "/release.toml", "/rustfmt.toml", ".gitignore"]
1616

@@ -24,11 +24,9 @@ maintenance = { status = "actively-developed" }
2424
members = ["binding-generator"]
2525

2626
[dependencies]
27-
# todo: MSRV, allow version to go 2.5.0 and above when MSRV is 1.81.0
28-
half = { version = "2, <2.5.0", optional = true }
27+
half = { version = "2", optional = true }
2928
libc = "0.2"
3029
num-traits = "0.2"
31-
once_cell = "1"
3230
# version 0.8.20 doesn't contain the deficiency mentioned in https://deps.rs/crate/opencv/0.59.0#vulnerabilities
3331
rgb = { version = "0.8.20", default-features = false, features = ["argb"], optional = true }
3432

@@ -42,7 +40,6 @@ cc = { version = "1.0.83", features = ["parallel"] }
4240
dunce = "1"
4341
# jobserver-0.1.25 is the first one that has Client::available() method
4442
jobserver = "0.1.25"
45-
once_cell = "1"
4643
pkg-config = "0.3"
4744
semver = "1"
4845
shlex = { version = "1.3", default-features = false }
@@ -57,7 +54,6 @@ cc = { version = "1.0.83", features = ["parallel"] }
5754
dunce = "1"
5855
# jobserver-0.1.25 is the first one that has Client::available() method
5956
jobserver = "0.1.25"
60-
once_cell = "1"
6157
pkg-config = "0.3"
6258
semver = "1"
6359
shlex = { version = "1.3", default-features = false }

binding-generator/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version = "0.97.0"
77
license = "MIT"
88
authors = ["Pro <[email protected]>"]
99
edition = "2021"
10-
rust-version = "1.77.0"
10+
rust-version = "1.81.0"
1111
exclude = ["release.toml"]
1212

1313
[lib]
@@ -16,15 +16,13 @@ exclude = ["release.toml"]
1616
clang = { version = "2", features = ["clang_6_0"] }
1717
clang-sys = { version = "1", features = ["clang_6_0"] }
1818
dunce = "1"
19-
once_cell = "1" # replace with std::sync::LazyLock when MSRV is 1.80
2019
percent-encoding = { version = "2", default-features = false }
2120
regex = "1"
2221
shlex = { version = "1.3", default-features = false }
2322

2423
[dev-dependencies]
2524
tempfile = { version = "3", default-features = false }
26-
# todo: MSRV, bump to 0.7 when MSRV is 1.80
27-
criterion = "0.5"
25+
criterion = "0.7"
2826

2927
[features]
3028
clang-runtime = ["clang/runtime", "clang-sys/runtime"]

binding-generator/src/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::borrow::Cow;
22
use std::fmt::Display;
33
use std::path::{Path, PathBuf};
4+
use std::sync::LazyLock;
45
use std::{env, fmt};
56

67
use clang::Entity;
78
use dunce::canonicalize;
8-
use once_cell::sync::Lazy;
99

10-
pub static EMIT_DEBUG: Lazy<bool> = Lazy::new(|| env::var("OPENCV_BINDING_GENERATOR_EMIT_DEBUG").is_ok_and(|v| v == "1"));
10+
pub static EMIT_DEBUG: LazyLock<bool> = LazyLock::new(|| env::var("OPENCV_BINDING_GENERATOR_EMIT_DEBUG").is_ok_and(|v| v == "1"));
1111

1212
#[derive(Clone, Debug)]
1313
pub struct LocationName<'me> {

binding-generator/src/func.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use std::borrow::Cow::{Borrowed, Owned};
33
use std::fmt;
44
use std::ops::ControlFlow;
55
use std::rc::Rc;
6+
use std::sync::LazyLock;
67

78
use clang::{Availability, Entity, EntityKind, ExceptionSpecification};
89
pub use desc::{FuncCppBody, FuncDesc, FuncRustBody, FuncRustExtern};
910
pub use func_matcher::{FuncMatchProperties, FuncMatcher, Pred, UsageTracker};
1011
pub use kind::{FuncKind, OperatorKind, ReturnKind};
11-
use once_cell::sync::Lazy;
1212
use regex::bytes::Regex;
1313
use slice_arg_finder::SliceArgFinder;
1414

@@ -366,7 +366,7 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
366366
};
367367
out.to_mut().replace_range(idx..idx + OVERLOAD.len(), &rep);
368368
}
369-
static COPY_BRIEF: Lazy<Regex> = Lazy::new(|| Regex::new(r"@copybrief\s+(\w+)").unwrap());
369+
static COPY_BRIEF: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"@copybrief\s+(\w+)").unwrap());
370370
out.to_mut().replace_in_place_regex_cb(&COPY_BRIEF, |comment, caps| {
371371
let copy_name = caps.get(1).map(|(s, e)| &comment[s..e]).expect("Impossible");
372372
let mut copy_full_name = self.cpp_namespace().into_owned();

binding-generator/src/settings.rs

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ macro_rules! pred {
4040
}
4141

4242
use std::collections::{BTreeSet, HashMap, HashSet};
43+
use std::sync::LazyLock;
4344

4445
pub use argument_names::{ARGUMENT_NAMES_MULTIPLE_SLICE, ARGUMENT_NAMES_NOT_SLICE, ARGUMENT_NAMES_USERDATA};
4546
pub use argument_override::{
@@ -64,7 +65,6 @@ pub use implemented::{
6465
IMPLEMENTED_CONST_GENERICS, IMPLEMENTED_FUNCTION_LIKE_MACROS, IMPLEMENTED_GENERICS, IMPLEMENTED_MANUAL_DEBUG,
6566
IMPLEMENTED_SYSTEM_CLASSES,
6667
};
67-
use once_cell::sync::Lazy;
6868
pub use property_tweaks::{property_tweaks_factory, PropertyReadWrite, PropertyTweak, PropertyTweaks};
6969

7070
use crate::func::{FuncMatcher, UsageTracker};
@@ -179,7 +179,7 @@ impl Settings {
179179
/// map of reserved Rust keywords and their replacement to be used in var, function and class names
180180
/// key: reserved keyword
181181
/// value: replacement
182-
pub static RESERVED_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| {
182+
pub static RESERVED_RENAME: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
183183
HashMap::from([
184184
("box", "box_"),
185185
("fn", "fn_"),
@@ -197,7 +197,7 @@ pub static RESERVED_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| {
197197
});
198198

199199
/// cpp_name(Reference) => ( rust_name(Reference(No)), cpp_name(Reference) )
200-
pub static PRIMITIVE_TYPEDEFS: Lazy<HashMap<&str, (&str, &str)>> = Lazy::new(|| {
200+
pub static PRIMITIVE_TYPEDEFS: LazyLock<HashMap<&str, (&str, &str)>> = LazyLock::new(|| {
201201
HashMap::from([
202202
("size_t", ("size_t", "size_t")),
203203
("ptrdiff_t", ("ptrdiff_t", "ptrdiff_t")),
@@ -216,11 +216,11 @@ pub static PRIMITIVE_TYPEDEFS: Lazy<HashMap<&str, (&str, &str)>> = Lazy::new(||
216216
])
217217
});
218218

219-
pub static STATIC_RUST_MODULES: Lazy<BTreeSet<&str>> = Lazy::new(|| BTreeSet::from(["core", "sys", "types"]));
219+
pub static STATIC_RUST_MODULES: LazyLock<BTreeSet<&str>> = LazyLock::new(|| BTreeSet::from(["core", "sys", "types"]));
220220

221221
/// Types that can be used as `Mat` element
222222
/// cpp_name(Reference)
223-
pub static DATA_TYPES: Lazy<HashSet<&str>> = Lazy::new(|| {
223+
pub static DATA_TYPES: LazyLock<HashSet<&str>> = LazyLock::new(|| {
224224
HashSet::from([
225225
"unsigned char",
226226
"char",
@@ -249,39 +249,40 @@ pub static DATA_TYPES: Lazy<HashSet<&str>> = Lazy::new(|| {
249249

250250
/// Types that can be used as `Mat` element since OpenCV 5.0
251251
/// cpp_name(Reference)
252-
pub static DATA_TYPES_5_0: Lazy<HashSet<&str>> =
253-
Lazy::new(|| HashSet::from(["uint32_t", "bfloat", "bfloat16_t", "uint64_t", "int64_t", "bool"]));
252+
pub static DATA_TYPES_5_0: LazyLock<HashSet<&str>> =
253+
LazyLock::new(|| HashSet::from(["uint32_t", "bfloat", "bfloat16_t", "uint64_t", "int64_t", "bool"]));
254254

255-
pub static NO_SKIP_NAMESPACE_IN_LOCALNAME: Lazy<HashMap<Option<SupportedModule>, HashMap<&str, &str>>> = Lazy::new(|| {
256-
HashMap::from([
257-
(None, HashMap::from([("detail", "Detail")])),
258-
(Some(SupportedModule::Calib3d), HashMap::from([("fisheye", "Fisheye")])),
259-
(Some(SupportedModule::CudaBgSegm), HashMap::from([("cuda", "CUDA")])),
260-
(Some(SupportedModule::CudaCodec), HashMap::from([("cudacodec", "CUDA")])),
261-
(Some(SupportedModule::CudaFeatures2d), HashMap::from([("cuda", "CUDA")])),
262-
(Some(SupportedModule::CudaImgProc), HashMap::from([("cuda", "CUDA")])),
263-
(Some(SupportedModule::CudaLegacy), HashMap::from([("cuda", "CUDA")])),
264-
(Some(SupportedModule::CudaObjDetect), HashMap::from([("cuda", "CUDA")])),
265-
(Some(SupportedModule::CudaOptFlow), HashMap::from([("cuda", "CUDA")])),
266-
(Some(SupportedModule::CudaStereo), HashMap::from([("cuda", "CUDA")])),
267-
(Some(SupportedModule::Gapi), HashMap::from([("imgproc", "ImgProc")])),
268-
(Some(SupportedModule::Mcc), HashMap::from([("mcc", "MCC")])),
269-
(Some(SupportedModule::Rapid), HashMap::from([("rapid", "Rapid")])),
270-
(
271-
Some(SupportedModule::Rgbd),
272-
HashMap::from([
273-
("dynafu", "Dynafu"),
274-
("kinfu", "Kinfu"),
275-
("colored_kinfu", "ColoredKinfu"),
276-
("linemod", "LineMod"),
277-
]),
278-
),
279-
(Some(SupportedModule::Stitching), HashMap::from([("fisheye", "Fisheye")])),
280-
(Some(SupportedModule::SuperRes), HashMap::from([("superres", "SuperRes")])),
281-
])
282-
});
255+
pub static NO_SKIP_NAMESPACE_IN_LOCALNAME: LazyLock<HashMap<Option<SupportedModule>, HashMap<&str, &str>>> =
256+
LazyLock::new(|| {
257+
HashMap::from([
258+
(None, HashMap::from([("detail", "Detail")])),
259+
(Some(SupportedModule::Calib3d), HashMap::from([("fisheye", "Fisheye")])),
260+
(Some(SupportedModule::CudaBgSegm), HashMap::from([("cuda", "CUDA")])),
261+
(Some(SupportedModule::CudaCodec), HashMap::from([("cudacodec", "CUDA")])),
262+
(Some(SupportedModule::CudaFeatures2d), HashMap::from([("cuda", "CUDA")])),
263+
(Some(SupportedModule::CudaImgProc), HashMap::from([("cuda", "CUDA")])),
264+
(Some(SupportedModule::CudaLegacy), HashMap::from([("cuda", "CUDA")])),
265+
(Some(SupportedModule::CudaObjDetect), HashMap::from([("cuda", "CUDA")])),
266+
(Some(SupportedModule::CudaOptFlow), HashMap::from([("cuda", "CUDA")])),
267+
(Some(SupportedModule::CudaStereo), HashMap::from([("cuda", "CUDA")])),
268+
(Some(SupportedModule::Gapi), HashMap::from([("imgproc", "ImgProc")])),
269+
(Some(SupportedModule::Mcc), HashMap::from([("mcc", "MCC")])),
270+
(Some(SupportedModule::Rapid), HashMap::from([("rapid", "Rapid")])),
271+
(
272+
Some(SupportedModule::Rgbd),
273+
HashMap::from([
274+
("dynafu", "Dynafu"),
275+
("kinfu", "Kinfu"),
276+
("colored_kinfu", "ColoredKinfu"),
277+
("linemod", "LineMod"),
278+
]),
279+
),
280+
(Some(SupportedModule::Stitching), HashMap::from([("fisheye", "Fisheye")])),
281+
(Some(SupportedModule::SuperRes), HashMap::from([("superres", "SuperRes")])),
282+
])
283+
});
283284

284-
pub static PREVENT_VECTOR_TYPEDEF_GENERATION: Lazy<HashSet<&str>> = Lazy::new(|| {
285+
pub static PREVENT_VECTOR_TYPEDEF_GENERATION: LazyLock<HashSet<&str>> = LazyLock::new(|| {
285286
HashSet::from([
286287
// `MatShape` is an alias to `Vector<i32>` and this leads to duplication of definition for the `Vector<Vector<i32>>` type
287288
"cv::dnn::MatShape",
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
use std::collections::HashSet;
2-
3-
use once_cell::sync::Lazy;
2+
use std::sync::LazyLock;
43

54
use crate::element::UNNAMED;
65

76
/// List of C++ argument names that are allowed to be userdata for a callback
8-
pub static ARGUMENT_NAMES_USERDATA: Lazy<HashSet<&str>> =
9-
Lazy::new(|| HashSet::from(["userdata", "userData", "cookie", UNNAMED]));
7+
pub static ARGUMENT_NAMES_USERDATA: LazyLock<HashSet<&str>> =
8+
LazyLock::new(|| HashSet::from(["userdata", "userData", "cookie", UNNAMED]));
109

1110
/// List of C++ argument names that are forbidden to be slice arguments
12-
pub static ARGUMENT_NAMES_NOT_SLICE: Lazy<HashSet<&str>> = Lazy::new(|| HashSet::from(["rmsd"]));
11+
pub static ARGUMENT_NAMES_NOT_SLICE: LazyLock<HashSet<&str>> = LazyLock::new(|| HashSet::from(["rmsd"]));
1312

1413
/// List of C++ argument names that can hint on multiple connected slice arguments in a function
15-
pub static ARGUMENT_NAMES_MULTIPLE_SLICE: Lazy<HashSet<&str>> =
16-
Lazy::new(|| HashSet::from(["a", "b", "src", "dst", "lut", "globalsize", "localsize"]));
14+
pub static ARGUMENT_NAMES_MULTIPLE_SLICE: LazyLock<HashSet<&str>> =
15+
LazyLock::new(|| HashSet::from(["a", "b", "src", "dst", "lut", "globalsize", "localsize"]));
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::collections::HashMap;
2-
3-
use once_cell::sync::Lazy;
2+
use std::sync::LazyLock;
43

54
use crate::constant::ValueKind;
65

76
/// (rust_name, value_kind)
8-
pub static CONST_TYPE_OVERRIDE: Lazy<HashMap<&str, ValueKind>> =
9-
Lazy::new(|| HashMap::from([("Mat_AUTO_STEP", ValueKind::Usize)]));
7+
pub static CONST_TYPE_OVERRIDE: LazyLock<HashMap<&str, ValueKind>> =
8+
LazyLock::new(|| HashMap::from([("Mat_AUTO_STEP", ValueKind::Usize)]));

binding-generator/src/settings/element_exclude_kind.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::collections::HashMap;
2-
3-
use once_cell::sync::Lazy;
2+
use std::sync::LazyLock;
43

54
use crate::element::ExcludeKind;
65

76
/// cpp_name(Reference)
8-
pub static ELEMENT_EXCLUDE_KIND: Lazy<HashMap<&str, ExcludeKind>> = Lazy::new(|| {
7+
pub static ELEMENT_EXCLUDE_KIND: LazyLock<HashMap<&str, ExcludeKind>> = LazyLock::new(|| {
98
HashMap::from([
109
("cv::face::FacemarkLBF::BBox", ExcludeKind::Excluded), // not used, not exported in windows dll
1110
("CV_DEPRECATED", ExcludeKind::Ignored),

binding-generator/src/settings/element_export_tweak.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use std::collections::HashMap;
2-
3-
use once_cell::sync::Lazy;
2+
use std::sync::LazyLock;
43

54
use crate::ExportConfig;
65

76
/// Manual export config adjustments in the form of "cpp_name(Reference)" => tweak function. If the export config is not
87
/// detected from the sources, an `ExportConfig::default()` is passed to the function.
98
#[allow(clippy::type_complexity)]
10-
pub static ELEMENT_EXPORT_TWEAK: Lazy<HashMap<&str, fn(ExportConfig) -> Option<ExportConfig>>> = Lazy::new(|| {
9+
pub static ELEMENT_EXPORT_TWEAK: LazyLock<HashMap<&str, fn(ExportConfig) -> Option<ExportConfig>>> = LazyLock::new(|| {
1110
HashMap::from([
1211
("VADisplay", ExportConfig::export as _),
1312
("VASurfaceID", ExportConfig::export as _),

binding-generator/src/settings/func_inject.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub type FuncFactory = fn() -> Func<'static, 'static>;
1515
pub fn func_inject_factory(module: SupportedModule) -> FuncInject {
1616
match module {
1717
SupportedModule::Core => vec![
18-
(|| {
18+
|| {
1919
Func::new_desc(
2020
FuncDesc::new(
2121
InstanceMethod(ClassDesc::cv_matconstiterator()),
@@ -28,7 +28,7 @@ pub fn func_inject_factory(module: SupportedModule) -> FuncInject {
2828
)
2929
.cpp_body(FuncCppBody::ManualCall("instance->m->type()".into())),
3030
)
31-
}) as FuncFactory, // todo: remove this cast when MSRV allows
31+
},
3232
|| {
3333
Func::new_desc(FuncDesc::new(
3434
InstanceMethod(ClassDesc::cv_mat()),
@@ -83,8 +83,7 @@ pub fn func_inject_factory(module: SupportedModule) -> FuncInject {
8383
)),
8484
Field::new_desc(FieldDesc::new(
8585
"n",
86-
// todo, MSRV: remove `as_slice()` when MSRV allows
87-
TypeRefDesc::int().with_type_hint(TypeRefTypeHint::LenForSlice(["vec".to_string()].as_slice().into(), 1)),
86+
TypeRefDesc::int().with_type_hint(TypeRefTypeHint::LenForSlice(["vec".to_string()].into(), 1)),
8887
)),
8988
],
9089
TypeRefDesc::cv_input_array()

0 commit comments

Comments
 (0)