Skip to content

cargo clippy --fix --all-features -- -Wclippy::use_self #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/duckdb/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl From<FromSqlError> for Error {
FromSqlError::OutOfRange(val) => Self::IntegralValueOutOfRange(UNKNOWN_COLUMN, val),
#[cfg(feature = "uuid")]
FromSqlError::InvalidUuidSize(_) => {
Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
Self::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
}
FromSqlError::Other(source) => Self::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, source),
_ => Self::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, Box::new(err)),
Expand Down
2 changes: 1 addition & 1 deletion crates/duckdb/src/polars_dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Polars<'stmt> {

impl<'stmt> Polars<'stmt> {
#[inline]
pub(crate) fn new(stmt: &'stmt Statement<'stmt>) -> Polars<'stmt> {
pub(crate) fn new(stmt: &'stmt Statement<'stmt>) -> Self {
Polars { stmt: Some(stmt) }
}

Expand Down
4 changes: 2 additions & 2 deletions crates/duckdb/src/types/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl FromSql for NaiveDateTime {
"%F"
}
};
NaiveDateTime::parse_from_str(s, format).map_err(|err| FromSqlError::Other(Box::new(err)))
Self::parse_from_str(s, format).map_err(|err| FromSqlError::Other(Box::new(err)))
}
_ => Err(FromSqlError::InvalidType),
}
Expand Down Expand Up @@ -139,7 +139,7 @@ impl FromSql for Duration {

match nanos.try_into() {
Ok(nanos) => {
if let Some(duration) = Duration::new(seconds, nanos) {
if let Some(duration) = Self::new(seconds, nanos) {
Ok(duration)
} else {
Err(FromSqlError::Other("Invalid duration".into()))
Expand Down
6 changes: 3 additions & 3 deletions crates/duckdb/src/types/from_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl PartialEq for FromSqlError {
(Self::InvalidType, Self::InvalidType) => true,
(Self::OutOfRange(n1), Self::OutOfRange(n2)) => n1 == n2,
#[cfg(feature = "uuid")]
(FromSqlError::InvalidUuidSize(s1), FromSqlError::InvalidUuidSize(s2)) => s1 == s2,
(Self::InvalidUuidSize(s1), Self::InvalidUuidSize(s2)) => s1 == s2,
(..) => false,
}
}
Expand All @@ -43,7 +43,7 @@ impl fmt::Display for FromSqlError {
Self::InvalidType => write!(f, "Invalid type"),
Self::OutOfRange(i) => write!(f, "Value {i} out of range"),
#[cfg(feature = "uuid")]
FromSqlError::InvalidUuidSize(s) => {
Self::InvalidUuidSize(s) => {
write!(f, "Cannot read UUID value out of {s} byte blob")
}
Self::Other(ref err) => err.fmt(f),
Expand Down Expand Up @@ -240,7 +240,7 @@ impl FromSql for uuid::Uuid {
match value {
ValueRef::Text(..) => value
.as_str()
.and_then(|s| uuid::Uuid::parse_str(s).map_err(|_| FromSqlError::InvalidUuidSize(s.len()))),
.and_then(|s| Self::parse_str(s).map_err(|_| FromSqlError::InvalidUuidSize(s.len()))),
ValueRef::Blob(..) => value
.as_blob()
.and_then(|bytes| {
Expand Down
2 changes: 1 addition & 1 deletion crates/duckdb/src/types/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl FromSql for Url {
match value {
ValueRef::Text(s) => {
let s = std::str::from_utf8(s).map_err(|e| FromSqlError::Other(Box::new(e)))?;
Url::parse(s).map_err(|e| FromSqlError::Other(Box::new(e)))
Self::parse(s).map_err(|e| FromSqlError::Other(Box::new(e)))
}
_ => Err(FromSqlError::InvalidType),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/duckdb/src/types/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl From<isize> for Value {
#[cfg(feature = "uuid")]
impl From<uuid::Uuid> for Value {
#[inline]
fn from(id: uuid::Uuid) -> Value {
Value::Text(id.to_string())
fn from(id: uuid::Uuid) -> Self {
Self::Text(id.to_string())
}
}

Expand Down
14 changes: 7 additions & 7 deletions crates/duckdb/src/vscalar/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ pub enum ArrowScalarParams {
impl AsRef<[DataType]> for ArrowScalarParams {
fn as_ref(&self) -> &[DataType] {
match self {
ArrowScalarParams::Exact(params) => params.as_ref(),
ArrowScalarParams::Variadic(param) => std::slice::from_ref(param),
Self::Exact(params) => params.as_ref(),
Self::Variadic(param) => std::slice::from_ref(param),
}
}
}

impl From<ArrowScalarParams> for ScalarParams {
fn from(params: ArrowScalarParams) -> Self {
match params {
ArrowScalarParams::Exact(params) => ScalarParams::Exact(
ArrowScalarParams::Exact(params) => Self::Exact(
params
.into_iter()
.map(|v| LogicalTypeId::try_from(&v).expect("type should be converted").into())
.collect(),
),
ArrowScalarParams::Variadic(param) => ScalarParams::Variadic(
ArrowScalarParams::Variadic(param) => Self::Variadic(
LogicalTypeId::try_from(&param)
.expect("type should be converted")
.into(),
Expand All @@ -58,15 +58,15 @@ pub struct ArrowFunctionSignature {
impl ArrowFunctionSignature {
/// Create an exact function signature
pub fn exact(params: Vec<DataType>, return_type: DataType) -> Self {
ArrowFunctionSignature {
Self {
parameters: Some(ArrowScalarParams::Exact(params)),
return_type,
}
}

/// Create a variadic function signature
pub fn variadic(param: DataType, return_type: DataType) -> Self {
ArrowFunctionSignature {
Self {
parameters: Some(ArrowScalarParams::Variadic(param)),
return_type,
}
Expand Down Expand Up @@ -152,7 +152,7 @@ mod test {

impl Default for MockState {
fn default() -> Self {
MockState {
Self {
info: "some meta".to_string(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/duckdb/src/vscalar/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl ScalarFunction {
duckdb_scalar_function_set_extra_info(self.ptr, extra_info, destroy);
}

pub fn set_extra_info<T: Default>(&self) -> &ScalarFunction {
pub fn set_extra_info<T: Default>(&self) -> &Self {
unsafe {
let t = Box::new(T::default());
let c_void = Box::into_raw(t) as *mut c_void;
Expand Down
6 changes: 3 additions & 3 deletions crates/duckdb/src/vscalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ pub struct ScalarFunctionSignature {
impl ScalarFunctionSignature {
/// Create an exact function signature
pub fn exact(params: Vec<LogicalTypeHandle>, return_type: LogicalTypeHandle) -> Self {
ScalarFunctionSignature {
Self {
parameters: Some(ScalarParams::Exact(params)),
return_type,
}
}

/// Create a variadic function signature
pub fn variadic(param: LogicalTypeHandle, return_type: LogicalTypeHandle) -> Self {
ScalarFunctionSignature {
Self {
parameters: Some(ScalarParams::Variadic(param)),
return_type,
}
Expand Down Expand Up @@ -201,7 +201,7 @@ mod test {

impl Default for TestState {
fn default() -> Self {
TestState { inner: 42 }
Self { inner: 42 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/duckdb/src/vtab/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl TableFunction {
///
/// # Arguments
/// * `name`: The name of the table function
pub fn set_name(&self, name: &str) -> &TableFunction {
pub fn set_name(&self, name: &str) -> &Self {
unsafe {
let string = CString::from_vec_unchecked(name.as_bytes().into());
duckdb_table_function_set_name(self.ptr, string.as_ptr());
Expand Down
Loading