Skip to content

Commit

Permalink
Fix clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbiedert committed Jan 12, 2025
1 parent 3e5a768 commit ac11d30
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 64 deletions.
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ derive_builder = "0.20.2"
heck = "0.5.0"
log = "0.4.14"
serde = "1.0.203"

[workspace.lints.clippy]
correctness = { level = "deny", priority = -1 }
suspicious = { level = "deny", priority = -1 }
complexity = { level = "deny", priority = -1 }
perf = { level = "deny", priority = -1 }
style = { level = "deny", priority = -1 }
pedantic = { level = "deny", priority = -1 }
nursery = { level = "deny", priority = -1 } # We might want to disable this if it causes issues.
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ keywords = ["ffi", "code-generation", "bindings"]
categories = ["api-bindings", "development-tools::ffi"]
version = "0.14.27"
edition = "2021"
rust-version = "1.83"
license = "MIT"
documentation = "https://docs.rs/interoptopus/"
repository = "https://github.com/ralfbiedert/interoptopus"
Expand Down
102 changes: 51 additions & 51 deletions crates/core/src/lang/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
}
}

unsafe impl<'a, T> CTypeInfo for &'a T
unsafe impl<T> CTypeInfo for &'_ T
where
T: CTypeInfo + Sized + 'static,
{
Expand All @@ -137,7 +137,7 @@ where
}
}

unsafe impl<'a, T> CTypeInfo for &'a mut T
unsafe impl<T> CTypeInfo for &'_ mut T
where
T: CTypeInfo + Sized + 'static,
{
Expand All @@ -164,7 +164,7 @@ where
}
}

unsafe impl<'a, T> CTypeInfo for Option<&'a T>
unsafe impl<T> CTypeInfo for Option<&'_ T>
where
T: CTypeInfo + Sized + 'static,
{
Expand All @@ -173,7 +173,7 @@ where
}
}

unsafe impl<'a, T> CTypeInfo for Option<&'a mut T>
unsafe impl<T> CTypeInfo for Option<&'_ mut T>
where
T: CTypeInfo + Sized + 'static,
{
Expand Down Expand Up @@ -213,22 +213,22 @@ where
}
}

unsafe impl<'a, T1, R> CTypeInfo for Option<extern "C" fn(T1) -> R>
unsafe impl<T1, R> CTypeInfo for Option<extern "C" fn(T1) -> R>
where
T1: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(vec![Parameter::new("x0".to_string(), T1::type_info())], R::type_info());
CType::FnPointer(FnPointerType::new(sig))
}
}

unsafe impl<'a, T1, T2, R> CTypeInfo for extern "C" fn(T1, T2) -> R
unsafe impl<T1, T2, R> CTypeInfo for extern "C" fn(T1, T2) -> R
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -239,11 +239,11 @@ where
}
}

unsafe impl<'a, T1, T2, R> CTypeInfo for Option<extern "C" fn(T1, T2) -> R>
unsafe impl<T1, T2, R> CTypeInfo for Option<extern "C" fn(T1, T2) -> R>
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -254,12 +254,12 @@ where
}
}

unsafe impl<'a, T1, T2, T3, R> CTypeInfo for extern "C" fn(T1, T2, T3) -> R
unsafe impl<T1, T2, T3, R> CTypeInfo for extern "C" fn(T1, T2, T3) -> R
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
T3: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
T3: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -274,12 +274,12 @@ where
}
}

unsafe impl<'a, T1, T2, T3, R> CTypeInfo for Option<extern "C" fn(T1, T2, T3) -> R>
unsafe impl<T1, T2, T3, R> CTypeInfo for Option<extern "C" fn(T1, T2, T3) -> R>
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
T3: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
T3: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -294,13 +294,13 @@ where
}
}

unsafe impl<'a, T1, T2, T3, T4, R> CTypeInfo for extern "C" fn(T1, T2, T3, T4) -> R
unsafe impl<T1, T2, T3, T4, R> CTypeInfo for extern "C" fn(T1, T2, T3, T4) -> R
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
T3: CTypeInfo + 'a,
T4: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
T3: CTypeInfo,
T4: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -316,13 +316,13 @@ where
}
}

unsafe impl<'a, T1, T2, T3, T4, R> CTypeInfo for Option<extern "C" fn(T1, T2, T3, T4) -> R>
unsafe impl<T1, T2, T3, T4, R> CTypeInfo for Option<extern "C" fn(T1, T2, T3, T4) -> R>
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
T3: CTypeInfo + 'a,
T4: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
T3: CTypeInfo,
T4: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -338,14 +338,14 @@ where
}
}

unsafe impl<'a, T1, T2, T3, T4, T5, R> CTypeInfo for extern "C" fn(T1, T2, T3, T4, T5) -> R
unsafe impl<T1, T2, T3, T4, T5, R> CTypeInfo for extern "C" fn(T1, T2, T3, T4, T5) -> R
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
T3: CTypeInfo + 'a,
T4: CTypeInfo + 'a,
T5: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
T3: CTypeInfo,
T4: CTypeInfo,
T5: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand All @@ -362,14 +362,14 @@ where
}
}

unsafe impl<'a, T1, T2, T3, T4, T5, R> CTypeInfo for Option<extern "C" fn(T1, T2, T3, T4, T5) -> R>
unsafe impl<T1, T2, T3, T4, T5, R> CTypeInfo for Option<extern "C" fn(T1, T2, T3, T4, T5) -> R>
where
T1: CTypeInfo + 'a,
T2: CTypeInfo + 'a,
T3: CTypeInfo + 'a,
T4: CTypeInfo + 'a,
T5: CTypeInfo + 'a,
R: CTypeInfo + 'a,
T1: CTypeInfo,
T2: CTypeInfo,
T3: CTypeInfo,
T4: CTypeInfo,
T5: CTypeInfo,
R: CTypeInfo,
{
fn type_info() -> CType {
let sig = FunctionSignature::new(
Expand Down
22 changes: 11 additions & 11 deletions crates/core/src/patterns/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ pub struct FFISlice<'a, T> {
_phantom: PhantomData<&'a T>,
}

impl<'a, T> Copy for FFISlice<'a, T> {}
impl<T> Copy for FFISlice<'_, T> {}

impl<'a, T> Clone for FFISlice<'a, T> {
impl<T> Clone for FFISlice<'_, T> {
fn clone(&self) -> Self {
*self
}
}

impl<'a, T> Default for FFISlice<'a, T> {
impl<T> Default for FFISlice<'_, T> {
fn default() -> Self {
Self {
data: null(),
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'a, T> From<&'a [T]> for FFISlice<'a, T> {
}
}

impl<'a, T> FFISlice<'a, T>
impl<T> FFISlice<'_, T>
where
T: 'static,
{
Expand All @@ -113,15 +113,15 @@ where
}
}

impl<'a, T> Deref for FFISlice<'a, T> {
impl<T> Deref for FFISlice<'_, T> {
type Target = [T];

fn deref(&self) -> &Self::Target {
self.as_slice()
}
}

unsafe impl<'a, T> CTypeInfo for FFISlice<'a, T>
unsafe impl<T> CTypeInfo for FFISlice<'_, T>
where
T: CTypeInfo,
{
Expand Down Expand Up @@ -152,7 +152,7 @@ pub struct FFISliceMut<'a, T> {
_phantom: PhantomData<&'a mut T>,
}

impl<'a, T> Default for FFISliceMut<'a, T> {
impl<T> Default for FFISliceMut<'_, T> {
fn default() -> Self {
Self {
data: null_mut(),
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a, T> FFISliceMut<'a, T> {
}
}

impl<'a, T> FFISliceMut<'a, T>
impl<T> FFISliceMut<'_, T>
where
T: 'static,
{
Expand All @@ -216,21 +216,21 @@ impl<'a, T> From<&'a mut [T]> for FFISliceMut<'a, T> {
}
}

impl<'a, T> Deref for FFISliceMut<'a, T> {
impl<T> Deref for FFISliceMut<'_, T> {
type Target = [T];

fn deref(&self) -> &Self::Target {
self.as_slice()
}
}

impl<'a, T> DerefMut for FFISliceMut<'a, T> {
impl<T> DerefMut for FFISliceMut<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.as_slice_mut()
}
}

unsafe impl<'a, T> CTypeInfo for FFISliceMut<'a, T>
unsafe impl<T> CTypeInfo for FFISliceMut<'_, T>
where
T: CTypeInfo,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/patterns/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct CStrPointer<'a> {
_phantom: PhantomData<&'a ()>,
}

impl<'a> Default for CStrPointer<'a> {
impl Default for CStrPointer<'_> {
fn default() -> Self {
Self {
ptr: null(),
Expand Down Expand Up @@ -120,7 +120,7 @@ impl<'a> CStrPointer<'a> {
}
}

unsafe impl<'a> CTypeInfo for CStrPointer<'a> {
unsafe impl CTypeInfo for CStrPointer<'_> {
fn type_info() -> CType {
CType::Pattern(TypePattern::CStrPointer)
}
Expand Down
1 change: 1 addition & 0 deletions crates/proc_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description = "Macros to produce Interoptopus item info."
authors = ["Ralf Biedert <[email protected]>"]
version = "0.14.23"
edition = "2021"
rust-version = "1.83"
license = "MIT"
keywords = ["ffi"]
categories = ["api-bindings", "development-tools::ffi"]
Expand Down

0 comments on commit ac11d30

Please sign in to comment.