Skip to content

Commit 4c92434

Browse files
committed
Update to Rust 2018 and fix clippy lints
1 parent bfaf34f commit 4c92434

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88

9+
* Update to Rust 2018. Does not affect compatibility with crates still using Rust 2015.
910
* Bump MSRV to 1.61 (first time officially defined)
1011
* Unconditionally support 128-bit integers.
12+
* Fix all clippy warnings
1113
* Setup Github Actions.
1214
* Fixup some minor typos in CHANGELOG.md, including an incorrect release date for 2.8.0.
1315

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ homepage = "https://github.com/slog-rs/slog"
1111
repository = "https://github.com/slog-rs/async"
1212
readme = "README.md"
1313
rust-version = "1.61"
14+
edition = "2021"
1415

1516
[features]
1617
nested-values = ["slog/nested-values"]

lib.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,24 @@
4949

5050
// {{{ Imports & meta
5151
#![warn(missing_docs)]
52-
53-
#[macro_use]
54-
extern crate slog;
55-
extern crate crossbeam_channel;
56-
extern crate take_mut;
57-
extern crate thread_local;
52+
#![warn(
53+
rust_2018_idioms,
54+
rust_2018_compatibility,
55+
rust_2021_compatibility,
56+
future_incompatible
57+
)]
58+
#![allow(
59+
// covered by mismatched_lifetime_syntaxes
60+
elided_lifetimes_in_paths,
61+
)]
5862

5963
use crossbeam_channel::Sender;
6064

65+
use slog::Drain;
66+
use slog::{b, o, record};
6167
use slog::{BorrowedKV, Level, Record, RecordStatic, SingleKV, KV};
6268
use slog::{Key, OwnedKVList, Serializer};
6369

64-
use slog::Drain;
6570
use std::fmt;
6671
use std::sync;
6772
use std::{io, thread};
@@ -182,7 +187,7 @@ impl Serializer for ToSendSerializer {
182187
fn emit_serde(
183188
&mut self,
184189
key: Key,
185-
value: &slog::SerdeValue,
190+
value: &dyn slog::SerdeValue,
186191
) -> slog::Result {
187192
let val = value.to_sendable();
188193
take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val))));
@@ -441,7 +446,7 @@ impl AsyncCore {
441446
) -> Result<
442447
&crossbeam_channel::Sender<AsyncMsg>,
443448
std::sync::PoisonError<
444-
sync::MutexGuard<crossbeam_channel::Sender<AsyncMsg>>,
449+
sync::MutexGuard<'_, crossbeam_channel::Sender<AsyncMsg>>,
445450
>,
446451
> {
447452
self.tl_sender.get_or_try(|| Ok(self.ref_sender.clone()))
@@ -506,7 +511,7 @@ impl AsyncRecord {
506511
/// Writes the record to a `Drain`.
507512
pub fn log_to<D: Drain>(self, drain: &D) -> Result<D::Ok, D::Err> {
508513
let rs = RecordStatic {
509-
location: &*self.location,
514+
location: &self.location,
510515
level: self.level,
511516
tag: &self.tag,
512517
};
@@ -524,7 +529,7 @@ impl AsyncRecord {
524529
/// Deconstruct this `AsyncRecord` into a record and `OwnedKVList`.
525530
pub fn as_record_values(&self, mut f: impl FnMut(&Record, &OwnedKVList)) {
526531
let rs = RecordStatic {
527-
location: &*self.location,
532+
location: &self.location,
528533
level: self.level,
529534
tag: &self.tag,
530535
};
@@ -580,6 +585,7 @@ impl Drop for AsyncCore {
580585
///
581586
/// More variants may be added in the future, without considering it a breaking change.
582587
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
588+
#[non_exhaustive]
583589
pub enum OverflowStrategy {
584590
/// The message gets dropped and a message with number of dropped is produced once there's
585591
/// space.
@@ -593,8 +599,6 @@ pub enum OverflowStrategy {
593599
Drop,
594600
/// The caller is blocked until there's enough space.
595601
Block,
596-
#[doc(hidden)]
597-
DoNotMatchAgainstThisAndReadTheDocs,
598602
}
599603

600604
/// `Async` builder
@@ -636,9 +640,6 @@ where
636640
OverflowStrategy::Block => (true, false),
637641
OverflowStrategy::Drop => (false, false),
638642
OverflowStrategy::DropAndReport => (false, true),
639-
OverflowStrategy::DoNotMatchAgainstThisAndReadTheDocs => {
640-
panic!("Invalid variant")
641-
}
642643
};
643644
AsyncBuilder {
644645
core: self.core.blocking(block),
@@ -737,6 +738,7 @@ impl Async {
737738
/// The wrapped drain must handle all results (`Drain<Ok=(),Error=Never>`)
738739
/// since there's no way to return it back. See `slog::DrainExt::fuse()` and
739740
/// `slog::DrainExt::ignore_res()` for typical error handling strategies.
741+
#[allow(clippy::new_ret_no_self)] // would break compat
740742
pub fn new<D: slog::Drain<Err = slog::Never, Ok = ()> + Send + 'static>(
741743
drain: D,
742744
) -> AsyncBuilder<D> {
@@ -807,6 +809,7 @@ impl Drop for Async {
807809
#[cfg(test)]
808810
mod test {
809811
use super::*;
812+
use slog::{info, warn};
810813
use std::sync::mpsc;
811814

812815
#[test]

0 commit comments

Comments
 (0)