Skip to content

Commit 6bfeb51

Browse files
committed
Update to Rust 2018 and fix clippy lints
1 parent 678dd96 commit 6bfeb51

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

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))));
@@ -507,7 +512,7 @@ impl AsyncCore {
507512
) -> Result<
508513
&crossbeam_channel::Sender<AsyncMsg>,
509514
std::sync::PoisonError<
510-
sync::MutexGuard<crossbeam_channel::Sender<AsyncMsg>>,
515+
sync::MutexGuard<'_, crossbeam_channel::Sender<AsyncMsg>>,
511516
>,
512517
> {
513518
self.tl_sender.get_or_try(|| Ok(self.ref_sender.clone()))
@@ -616,7 +621,7 @@ impl AsyncRecord {
616621
/// Writes the record to a `Drain`.
617622
pub fn log_to<D: Drain>(self, drain: &D) -> Result<D::Ok, D::Err> {
618623
let rs = RecordStatic {
619-
location: &*self.location,
624+
location: &self.location,
620625
level: self.level,
621626
tag: &self.tag,
622627
};
@@ -634,7 +639,7 @@ impl AsyncRecord {
634639
/// Deconstruct this `AsyncRecord` into a record and `OwnedKVList`.
635640
pub fn as_record_values(&self, mut f: impl FnMut(&Record, &OwnedKVList)) {
636641
let rs = RecordStatic {
637-
location: &*self.location,
642+
location: &self.location,
638643
level: self.level,
639644
tag: &self.tag,
640645
};
@@ -691,6 +696,7 @@ impl Drop for AsyncCore {
691696
///
692697
/// More variants may be added in the future, without considering it a breaking change.
693698
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
699+
#[non_exhaustive]
694700
pub enum OverflowStrategy {
695701
/// The message gets dropped and a message with number of dropped is produced once there's
696702
/// space.
@@ -704,8 +710,6 @@ pub enum OverflowStrategy {
704710
Drop,
705711
/// The caller is blocked until there's enough space.
706712
Block,
707-
#[doc(hidden)]
708-
DoNotMatchAgainstThisAndReadTheDocs,
709713
}
710714

711715
/// `Async` builder
@@ -747,9 +751,6 @@ where
747751
OverflowStrategy::Block => (true, false),
748752
OverflowStrategy::Drop => (false, false),
749753
OverflowStrategy::DropAndReport => (false, true),
750-
OverflowStrategy::DoNotMatchAgainstThisAndReadTheDocs => {
751-
panic!("Invalid variant")
752-
}
753754
};
754755
AsyncBuilder {
755756
core: self.core.blocking(block),
@@ -848,6 +849,7 @@ impl Async {
848849
/// The wrapped drain must handle all results (`Drain<Ok=(),Error=Never>`)
849850
/// since there's no way to return it back. See `slog::DrainExt::fuse()` and
850851
/// `slog::DrainExt::ignore_res()` for typical error handling strategies.
852+
#[allow(clippy::new_ret_no_self)] // would break compat
851853
pub fn new<D: slog::Drain<Err = slog::Never, Ok = ()> + Send + 'static>(
852854
drain: D,
853855
) -> AsyncBuilder<D> {
@@ -923,6 +925,7 @@ impl Drop for Async {
923925
mod test {
924926
use super::*;
925927
use std::sync::mpsc;
928+
use slog::{info, warn};
926929

927930
#[test]
928931
fn integration_test() {

0 commit comments

Comments
 (0)