From bde0fa657badf98226244d80b1dd53754042d148 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Wed, 8 Mar 2023 09:53:09 +0100 Subject: [PATCH 1/6] Fix documented MSRV The MSRV was updated to 1.54 in commit d4e508d. Update the MSRV specified in the Readme badge and in the clippy.toml to match the actual MSRV. --- .clippy.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.clippy.toml b/.clippy.toml index 4dd68bb5c..8eb9e0003 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,2 +1,2 @@ # Specify the minimum supported Rust version -msrv = "1.40.0" +msrv = "1.54.0" diff --git a/README.md b/README.md index e3df3246e..a67ece62f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# `cbindgen`   [![Build Status]][actions] [![Latest Version]][crates.io] [![Api Rustdoc]][rustdoc] [![Rust](https://img.shields.io/badge/rust-1.32%2B-blue.svg?maxAge=3600)](https://github.com/eqrion/cbindgen) +# `cbindgen`   [![Build Status]][actions] [![Latest Version]][crates.io] [![Api Rustdoc]][rustdoc] [![Rust](https://img.shields.io/badge/rust-1.54%2B-blue.svg?maxAge=3600)](https://github.com/eqrion/cbindgen) [Build Status]: https://github.com/eqrion/cbindgen/workflows/cbindgen/badge.svg [actions]: https://github.com/eqrion/cbindgen/actions From 616b7e87d46230ce0f26e12a6a0fc2c5b0bcae3e Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Wed, 8 Mar 2023 09:55:41 +0100 Subject: [PATCH 2/6] Fix clippy warning (1.40 -> 1.54) The clippy.toml suppresses warnings added in newer rust versions, so fixing the documented MSRV also shows new warnings. --- src/bindgen/cdecl.rs | 4 ++-- src/bindgen/dependencies.rs | 10 ++++------ src/bindgen/ir/annotation.rs | 8 ++++---- src/bindgen/ir/item.rs | 4 ++-- src/main.rs | 6 +++--- tests/tests.rs | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/bindgen/cdecl.rs b/src/bindgen/cdecl.rs index 7e2ad4e10..74ee669de 100644 --- a/src/bindgen/cdecl.rs +++ b/src/bindgen/cdecl.rs @@ -296,7 +296,7 @@ impl CDecl { ) { let align_length = out.line_length_for_align(); out.push_set_spaces(align_length); - for (i, &(ref arg_ident, ref arg_ty)) in args.iter().enumerate() { + for (i, (arg_ident, arg_ty)) in args.iter().enumerate() { if i != 0 { out.write(","); out.new_line(); @@ -315,7 +315,7 @@ impl CDecl { config: &Config, args: &[(Option, CDecl)], ) { - for (i, &(ref arg_ident, ref arg_ty)) in args.iter().enumerate() { + for (i, (arg_ident, arg_ty)) in args.iter().enumerate() { if i != 0 { out.write(", "); } diff --git a/src/bindgen/dependencies.rs b/src/bindgen/dependencies.rs index 870d12919..6a9873818 100644 --- a/src/bindgen/dependencies.rs +++ b/src/bindgen/dependencies.rs @@ -26,17 +26,15 @@ impl Dependencies { // Sort untagged enums and opaque structs into their own layers because they don't // depend on each other or anything else. let ordering = |a: &ItemContainer, b: &ItemContainer| match (a, b) { - (&ItemContainer::Enum(ref x), &ItemContainer::Enum(ref y)) + (ItemContainer::Enum(x), ItemContainer::Enum(y)) if x.tag.is_none() && y.tag.is_none() => { x.path.cmp(&y.path) } - (&ItemContainer::Enum(ref x), _) if x.tag.is_none() => Ordering::Less, - (_, &ItemContainer::Enum(ref x)) if x.tag.is_none() => Ordering::Greater, + (ItemContainer::Enum(x), _) if x.tag.is_none() => Ordering::Less, + (_, ItemContainer::Enum(x)) if x.tag.is_none() => Ordering::Greater, - (&ItemContainer::OpaqueItem(ref x), &ItemContainer::OpaqueItem(ref y)) => { - x.path.cmp(&y.path) - } + (ItemContainer::OpaqueItem(x), ItemContainer::OpaqueItem(y)) => x.path.cmp(&y.path), (&ItemContainer::OpaqueItem(_), _) => Ordering::Less, (_, &ItemContainer::OpaqueItem(_)) => Ordering::Greater, diff --git a/src/bindgen/ir/annotation.rs b/src/bindgen/ir/annotation.rs index 208a17778..c3c8db03d 100644 --- a/src/bindgen/ir/annotation.rs +++ b/src/bindgen/ir/annotation.rs @@ -130,19 +130,19 @@ impl AnnotationSet { pub fn list(&self, name: &str) -> Option> { match self.annotations.get(name) { - Some(&AnnotationValue::List(ref x)) => Some(x.clone()), + Some(AnnotationValue::List(x)) => Some(x.clone()), _ => None, } } pub fn atom(&self, name: &str) -> Option> { match self.annotations.get(name) { - Some(&AnnotationValue::Atom(ref x)) => Some(x.clone()), + Some(AnnotationValue::Atom(x)) => Some(x.clone()), _ => None, } } pub fn bool(&self, name: &str) -> Option { match self.annotations.get(name) { - Some(&AnnotationValue::Bool(ref x)) => Some(*x), + Some(AnnotationValue::Bool(x)) => Some(*x), _ => None, } } @@ -152,7 +152,7 @@ impl AnnotationSet { T: Default + FromStr, { match self.annotations.get(name) { - Some(&AnnotationValue::Atom(ref x)) => Some( + Some(AnnotationValue::Atom(x)) => Some( x.as_ref() .map_or(T::default(), |y| y.parse::().ok().unwrap()), ), diff --git a/src/bindgen/ir/item.rs b/src/bindgen/ir/item.rs index a1c3a7521..16d98f55d 100644 --- a/src/bindgen/ir/item.rs +++ b/src/bindgen/ir/item.rs @@ -219,12 +219,12 @@ impl ItemMap { F: FnMut(&T), { match self.data.get(path) { - Some(&ItemValue::Cfg(ref items)) => { + Some(ItemValue::Cfg(items)) => { for item in items { callback(item); } } - Some(&ItemValue::Single(ref item)) => { + Some(ItemValue::Single(item)) => { callback(item); } None => {} diff --git a/src/main.rs b/src/main.rs index e6dec459d..812366f49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,7 +157,7 @@ fn main() { .long("lang") .value_name("LANGUAGE") .help("Specify the language to output bindings in") - .possible_values(&["c++", "C++", "c", "C", "cython", "Cython"]), + .possible_values(["c++", "C++", "c", "C", "cython", "Cython"]), ) .arg( Arg::new("cpp-compat") @@ -176,7 +176,7 @@ fn main() { .long("style") .value_name("STYLE") .help("Specify the declaration style to use for bindings") - .possible_values(&["Both", "both", "Tag", "tag", "Type", "type"]), + .possible_values(["Both", "both", "Tag", "tag", "Type", "type"]), ) .arg( Arg::new("d") @@ -253,7 +253,7 @@ fn main() { "Specify the profile to use when expanding macros. \ Has no effect otherwise." ) - .possible_values(&["Debug", "debug", "Release", "release"]), + .possible_values(["Debug", "debug", "Release", "release"]), ) .arg( Arg::new("quiet") diff --git a/tests/tests.rs b/tests/tests.rs index 3b44eac3c..88a1c400e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -23,7 +23,7 @@ fn run_cbindgen( style: Option