diff --git a/.clippy.toml b/.clippy.toml index ec0fa1f1c..e9b576d3a 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1,2 +1,2 @@ # Specify the minimum supported Rust version -msrv = "1.57.0" +msrv = "1.64.0" diff --git a/src/bindgen/config.rs b/src/bindgen/config.rs index 9acc5bd1f..2c333a8c0 100644 --- a/src/bindgen/config.rs +++ b/src/bindgen/config.rs @@ -61,8 +61,10 @@ impl Language { /// Controls what type of line endings are used in the generated code. #[derive(Debug, Clone, Copy)] #[allow(clippy::upper_case_acronyms)] +#[derive(Default)] pub enum LineEndingStyle { /// Use Unix-style linefeed characters + #[default] LF, /// Use classic Mac-style carriage-return characters CR, @@ -72,11 +74,7 @@ pub enum LineEndingStyle { Native, } -impl Default for LineEndingStyle { - fn default() -> Self { - LineEndingStyle::LF - } -} + impl LineEndingStyle { pub fn as_str(&self) -> &'static str { @@ -214,7 +212,9 @@ deserialize_enum_str!(DocumentationLength); /// A style of Style to use when generating structs and enums. #[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Default)] pub enum Style { + #[default] Both, Tag, Type, @@ -245,11 +245,7 @@ impl Style { } } -impl Default for Style { - fn default() -> Self { - Style::Both - } -} + impl FromStr for Style { type Err = String; diff --git a/src/bindgen/ir/repr.rs b/src/bindgen/ir/repr.rs index 971320187..dbe62ab15 100644 --- a/src/bindgen/ir/repr.rs +++ b/src/bindgen/ir/repr.rs @@ -7,17 +7,15 @@ use syn::ext::IdentExt; use crate::bindgen::ir::ty::{IntKind, PrimitiveType}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Default)] pub enum ReprStyle { + #[default] Rust, C, Transparent, } -impl Default for ReprStyle { - fn default() -> Self { - ReprStyle::Rust - } -} + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct ReprType { diff --git a/src/bindgen/rename.rs b/src/bindgen/rename.rs index e58b7a5ae..69b33deba 100644 --- a/src/bindgen/rename.rs +++ b/src/bindgen/rename.rs @@ -29,8 +29,10 @@ impl<'a> IdentifierType<'a> { /// A rule to apply to an identifier when generating bindings. #[derive(Debug, Clone, Copy)] +#[derive(Default)] pub enum RenameRule { /// Do not apply any renaming. The default. + #[default] None, /// Converts the identifier to PascalCase and adds a context dependent prefix GeckoCase, @@ -93,11 +95,7 @@ impl RenameRule { } } -impl Default for RenameRule { - fn default() -> RenameRule { - RenameRule::None - } -} + impl FromStr for RenameRule { type Err = String; diff --git a/tests/depfile.rs b/tests/depfile.rs index 8dc1859f3..4a622bcc1 100644 --- a/tests/depfile.rs +++ b/tests/depfile.rs @@ -93,7 +93,7 @@ fn test_project(project_path: &str) { ); std::fs::remove_dir_all(build_dir).expect("Failed to remove old build directory"); - () + } macro_rules! test_file { diff --git a/tests/tests.rs b/tests/tests.rs index d978bd0b1..3846f326e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -251,7 +251,7 @@ fn run_compile_test( ); if generate_depfile { let depfile = depfile_contents.expect("No depfile generated"); - assert!(depfile.len() > 0); + assert!(!depfile.is_empty()); let mut rules = depfile.split(':'); let target = rules.next().expect("No target found"); assert_eq!(target, generated_file.as_os_str().to_str().unwrap());