mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Merge pull request #342 from djmitche/clippy-warnings
fix some clippy warnings, and make them errors for taskchampion-lib
This commit is contained in:
commit
889e1d1cdc
7 changed files with 14 additions and 22 deletions
|
@ -7,6 +7,11 @@
|
||||||
// docstrings for extern "C" functions are reflected into C, and do not benefit
|
// docstrings for extern "C" functions are reflected into C, and do not benefit
|
||||||
// from safety docs.
|
// from safety docs.
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
|
// deny some things that are typically warnings
|
||||||
|
#![deny(clippy::derivable_impls)]
|
||||||
|
#![deny(clippy::wrong_self_convention)]
|
||||||
|
#![deny(clippy::extra_unused_lifetimes)]
|
||||||
|
#![deny(clippy::unnecessary_to_owned)]
|
||||||
|
|
||||||
mod traits;
|
mod traits;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
|
@ -149,7 +149,7 @@ pub unsafe extern "C" fn tc_replica_new_on_disk(
|
||||||
// - caller will not use path after this call (convention)
|
// - caller will not use path after this call (convention)
|
||||||
let mut path = unsafe { TCString::val_from_arg(path) };
|
let mut path = unsafe { TCString::val_from_arg(path) };
|
||||||
let storage = StorageConfig::OnDisk {
|
let storage = StorageConfig::OnDisk {
|
||||||
taskdb_dir: path.to_path_buf()?,
|
taskdb_dir: path.to_path_buf_mut()?,
|
||||||
}
|
}
|
||||||
.into_storage()?;
|
.into_storage()?;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub unsafe extern "C" fn tc_server_new_local(
|
||||||
// - caller will not use server_dir after this call (convention)
|
// - caller will not use server_dir after this call (convention)
|
||||||
let mut server_dir = unsafe { TCString::val_from_arg(server_dir) };
|
let mut server_dir = unsafe { TCString::val_from_arg(server_dir) };
|
||||||
let server_config = ServerConfig::Local {
|
let server_config = ServerConfig::Local {
|
||||||
server_dir: server_dir.to_path_buf()?,
|
server_dir: server_dir.to_path_buf_mut()?,
|
||||||
};
|
};
|
||||||
let server = server_config.into_server()?;
|
let server = server_config.into_server()?;
|
||||||
// SAFETY: caller promises to free this server.
|
// SAFETY: caller promises to free this server.
|
||||||
|
|
|
@ -292,7 +292,7 @@ impl<'a> RustString<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn to_path_buf(&mut self) -> Result<PathBuf, std::str::Utf8Error> {
|
pub(crate) fn to_path_buf_mut(&mut self) -> Result<PathBuf, std::str::Utf8Error> {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
let path: OsString = {
|
let path: OsString = {
|
||||||
// on UNIX, we can use the bytes directly, without requiring that they
|
// on UNIX, we can use the bytes directly, without requiring that they
|
||||||
|
|
|
@ -386,7 +386,7 @@ pub unsafe extern "C" fn tc_task_get_annotations(task: *mut TCTask) -> TCAnnotat
|
||||||
///
|
///
|
||||||
/// Returns a TCString with NULL ptr field if the UDA does not exist.
|
/// Returns a TCString with NULL ptr field if the UDA does not exist.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn tc_task_get_uda<'a>(
|
pub unsafe extern "C" fn tc_task_get_uda(
|
||||||
task: *mut TCTask,
|
task: *mut TCTask,
|
||||||
ns: TCString,
|
ns: TCString,
|
||||||
key: TCString,
|
key: TCString,
|
||||||
|
@ -413,7 +413,7 @@ pub unsafe extern "C" fn tc_task_get_uda<'a>(
|
||||||
///
|
///
|
||||||
/// Returns NULL if the UDA does not exist.
|
/// Returns NULL if the UDA does not exist.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn tc_task_get_legacy_uda<'a>(task: *mut TCTask, key: TCString) -> TCString {
|
pub unsafe extern "C" fn tc_task_get_legacy_uda(task: *mut TCTask, key: TCString) -> TCString {
|
||||||
wrap(task, |task| {
|
wrap(task, |task| {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// - key is valid (promised by caller)
|
// - key is valid (promised by caller)
|
||||||
|
@ -708,11 +708,7 @@ pub unsafe extern "C" fn tc_task_set_uda(
|
||||||
wrap_mut(
|
wrap_mut(
|
||||||
task,
|
task,
|
||||||
|task| {
|
|task| {
|
||||||
task.set_uda(
|
task.set_uda(ns.as_str()?, key.as_str()?, value.as_str()?.to_string())?;
|
||||||
ns.as_str()?.to_string(),
|
|
||||||
key.as_str()?.to_string(),
|
|
||||||
value.as_str()?.to_string(),
|
|
||||||
)?;
|
|
||||||
Ok(TCResult::Ok)
|
Ok(TCResult::Ok)
|
||||||
},
|
},
|
||||||
TCResult::Error,
|
TCResult::Error,
|
||||||
|
@ -735,7 +731,7 @@ pub unsafe extern "C" fn tc_task_remove_uda(
|
||||||
wrap_mut(
|
wrap_mut(
|
||||||
task,
|
task,
|
||||||
|task| {
|
|task| {
|
||||||
task.remove_uda(ns.as_str()?.to_string(), key.as_str()?.to_string())?;
|
task.remove_uda(ns.as_str()?, key.as_str()?)?;
|
||||||
Ok(TCResult::Ok)
|
Ok(TCResult::Ok)
|
||||||
},
|
},
|
||||||
TCResult::Error,
|
TCResult::Error,
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::types::*;
|
||||||
|
|
||||||
/// TCUda contains the details of a UDA.
|
/// TCUda contains the details of a UDA.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Default)]
|
||||||
pub struct TCUda {
|
pub struct TCUda {
|
||||||
/// Namespace of the UDA. For legacy UDAs, this may have a NULL ptr field.
|
/// Namespace of the UDA. For legacy UDAs, this may have a NULL ptr field.
|
||||||
pub ns: TCString,
|
pub ns: TCString,
|
||||||
|
@ -58,16 +59,6 @@ impl PassByValue for TCUda {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TCUda {
|
|
||||||
fn default() -> Self {
|
|
||||||
TCUda {
|
|
||||||
ns: TCString::default(),
|
|
||||||
key: TCString::default(),
|
|
||||||
value: TCString::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// TCUdaList represents a list of UDAs.
|
/// TCUdaList represents a list of UDAs.
|
||||||
///
|
///
|
||||||
/// The content of this struct must be treated as read-only.
|
/// The content of this struct must be treated as read-only.
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn main() -> anyhow::Result<()> {
|
pub fn main() -> anyhow::Result<()> {
|
||||||
let arg = env::args().nth(1);
|
let arg = env::args().nth(1);
|
||||||
match arg.as_ref().map(|arg| arg.as_str()) {
|
match arg.as_deref() {
|
||||||
Some("codegen") => codegen(),
|
Some("codegen") => codegen(),
|
||||||
Some(arg) => anyhow::bail!("unknown xtask {}", arg),
|
Some(arg) => anyhow::bail!("unknown xtask {}", arg),
|
||||||
_ => anyhow::bail!("unknown xtask"),
|
_ => anyhow::bail!("unknown xtask"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue