Skip to content

Commit 0cfe2f3

Browse files
committed
Enable clippy lint impl_trait_in_params as "warn"
1 parent 3aaef62 commit 0cfe2f3

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ keywords = ["spdlog", "log", "logging"]
1515
categories = ["development-tools::debugging"]
1616

1717
[workspace.lints.clippy]
18+
impl_trait_in_params = "warn"
1819
must_use_candidate = "warn"
1920
unused_result_ok = "warn"
2021
unused_trait_names = "warn"

spdlog-internal/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
//!
66
//! [`spdlog-rs`]: https://crates.io/crates/spdlog-rs
77
8+
// The crate is not intended to be used directly by users, all public items are considered internal
9+
// API, so we don't care about this warning.
10+
#![allow(clippy::impl_trait_in_params)]
11+
812
pub mod pattern_parser;
913

1014
#[macro_export]

spdlog/src/periodic_worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl PeriodicWorker {
1111
// Panic if the `interval.is_zero()` is `true`.
1212
#[allow(clippy::mutex_atomic)]
1313
#[must_use]
14-
pub fn new(callback: impl Fn() -> bool + Send + 'static, interval: Duration) -> Self {
14+
pub fn new<F: Fn() -> bool + Send + 'static>(callback: F, interval: Duration) -> Self {
1515
if interval.is_zero() {
1616
panic!("PeriodicWorker: the interval cannot be zero")
1717
}

spdlog/src/test_utils/common.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ impl StringSink {
130130
}
131131
}
132132

133-
pub fn with(
134-
cb: impl FnOnce(
133+
pub fn with<F>(cb: F) -> Self
134+
where
135+
F: FnOnce(
135136
WriteSinkBuilder<Vec<u8>, PhantomData<Vec<u8>>>,
136137
) -> WriteSinkBuilder<Vec<u8>, PhantomData<Vec<u8>>>,
137-
) -> Self {
138+
{
138139
Self {
139140
underlying: cb(WriteSink::builder().target(vec![])).build().unwrap(),
140141
}
@@ -196,7 +197,10 @@ impl Default for NoModFormatter {
196197
//////////////////////////////////////////////////
197198

198199
#[must_use]
199-
pub fn build_test_logger(cb: impl FnOnce(&mut LoggerBuilder) -> &mut LoggerBuilder) -> Logger {
200+
pub fn build_test_logger<F>(cb: F) -> Logger
201+
where
202+
F: FnOnce(&mut LoggerBuilder) -> &mut LoggerBuilder,
203+
{
200204
let mut builder = Logger::builder();
201205
cb(builder.error_handler(|err| panic!("{}", err)));
202206
builder.build().unwrap()
@@ -214,18 +218,24 @@ macro_rules! assert_trait {
214218
pub use assert_trait;
215219

216220
#[must_use]
217-
pub fn echo_logger_from_pattern(
218-
pattern: impl Pattern + Clone + 'static,
221+
pub fn echo_logger_from_pattern<P>(
222+
pattern: P,
219223
name: Option<&'static str>,
220-
) -> (Logger, Arc<StringSink>) {
224+
) -> (Logger, Arc<StringSink>)
225+
where
226+
P: Pattern + Clone + 'static,
227+
{
221228
echo_logger_from_formatter(PatternFormatter::new(pattern), name)
222229
}
223230

224231
#[must_use]
225-
pub fn echo_logger_from_formatter(
226-
formatter: impl Formatter + 'static,
232+
pub fn echo_logger_from_formatter<P>(
233+
formatter: P,
227234
name: Option<&'static str>,
228-
) -> (Logger, Arc<StringSink>) {
235+
) -> (Logger, Arc<StringSink>)
236+
where
237+
P: Formatter + 'static,
238+
{
229239
let sink = Arc::new(StringSink::with(|b| b.formatter(formatter)));
230240

231241
let mut builder = Logger::builder();

spdlog/src/utils/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) use ref_str::*;
1010

1111
use crate::{Error, Result};
1212

13-
pub fn open_file(path: impl AsRef<Path>, truncate: bool) -> Result<File> {
13+
pub fn open_file<P: AsRef<Path>>(path: P, truncate: bool) -> Result<File> {
1414
if let Some(parent) = path.as_ref().parent() {
1515
if !parent.exists() {
1616
fs::create_dir_all(parent).map_err(Error::CreateDirectory)?;
@@ -31,8 +31,8 @@ pub fn open_file(path: impl AsRef<Path>, truncate: bool) -> Result<File> {
3131
.map_err(Error::OpenFile)
3232
}
3333

34-
pub fn open_file_bufw(
35-
path: impl AsRef<Path>,
34+
pub fn open_file_bufw<P: AsRef<Path>>(
35+
path: P,
3636
truncate: bool,
3737
capacity: Option<usize>,
3838
) -> Result<BufWriter<File>> {

0 commit comments

Comments
 (0)