Skip to content

Commit d3e3637

Browse files
authored
chore(ci): fix clippy warnings when using rust 1.83 (#250)
Signed-off-by: koushiro <[email protected]>
1 parent 3e6b9e2 commit d3e3637

File tree

5 files changed

+38
-39
lines changed

5 files changed

+38
-39
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ prost-types = { version = "0.12.0", optional = true }
2929
async-std = { version = "1", features = ["attributes"] }
3030
axum = "0.7"
3131
criterion = "0.5"
32+
futures = "0.3"
3233
http-types = "2"
3334
pyo3 = "0.22"
3435
quickcheck = "1"

examples/hyper.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use futures::future::BoxFuture;
12
use http_body_util::{combinators, BodyExt, Full};
23
use hyper::{
34
body::{Bytes, Incoming},
@@ -8,10 +9,8 @@ use hyper::{
89
use hyper_util::rt::TokioIo;
910
use prometheus_client::{encoding::text::encode, metrics::counter::Counter, registry::Registry};
1011
use std::{
11-
future::Future,
1212
io,
1313
net::{IpAddr, Ipv4Addr, SocketAddr},
14-
pin::Pin,
1514
sync::Arc,
1615
};
1716
use tokio::{
@@ -69,8 +68,7 @@ type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
6968
/// This function returns a HTTP handler (i.e. another function)
7069
pub fn make_handler(
7170
registry: Arc<Registry>,
72-
) -> impl Fn(Request<Incoming>) -> Pin<Box<dyn Future<Output = io::Result<Response<BoxBody>>> + Send>>
73-
{
71+
) -> impl Fn(Request<Incoming>) -> BoxFuture<'static, io::Result<Response<BoxBody>>> {
7472
// This closure accepts a request and responds with the OpenMetrics encoding of our metrics.
7573
move |_req: Request<Incoming>| {
7674
let reg = registry.clone();

src/encoding.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'a> From<protobuf::LabelSetEncoder<'a>> for LabelSetEncoder<'a> {
230230
}
231231
}
232232

233-
impl<'a> LabelSetEncoder<'a> {
233+
impl LabelSetEncoder<'_> {
234234
/// Encode the given label.
235235
pub fn encode_label(&mut self) -> LabelEncoder {
236236
for_both_mut!(self, LabelSetEncoderInner, e, e.encode_label().into())
@@ -271,7 +271,7 @@ impl<'a> From<protobuf::LabelEncoder<'a>> for LabelEncoder<'a> {
271271
}
272272
}
273273

274-
impl<'a> LabelEncoder<'a> {
274+
impl LabelEncoder<'_> {
275275
/// Encode a label.
276276
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
277277
for_both_mut!(
@@ -313,7 +313,7 @@ impl<'a> From<protobuf::LabelKeyEncoder<'a>> for LabelKeyEncoder<'a> {
313313
}
314314
}
315315

316-
impl<'a> std::fmt::Write for LabelKeyEncoder<'a> {
316+
impl std::fmt::Write for LabelKeyEncoder<'_> {
317317
fn write_str(&mut self, s: &str) -> std::fmt::Result {
318318
for_both_mut!(self, LabelKeyEncoderInner, e, e.write_str(s))
319319
}
@@ -390,7 +390,7 @@ impl EncodeLabelKey for String {
390390
}
391391
}
392392

393-
impl<'a> EncodeLabelKey for Cow<'a, str> {
393+
impl EncodeLabelKey for Cow<'_, str> {
394394
fn encode(&self, encoder: &mut LabelKeyEncoder) -> Result<(), std::fmt::Error> {
395395
EncodeLabelKey::encode(&self.as_ref(), encoder)
396396
}
@@ -453,14 +453,14 @@ enum LabelValueEncoderInner<'a> {
453453
Protobuf(protobuf::LabelValueEncoder<'a>),
454454
}
455455

456-
impl<'a> LabelValueEncoder<'a> {
456+
impl LabelValueEncoder<'_> {
457457
/// Finish encoding the label value.
458458
pub fn finish(self) -> Result<(), std::fmt::Error> {
459459
for_both!(self, LabelValueEncoderInner, e, e.finish())
460460
}
461461
}
462462

463-
impl<'a> std::fmt::Write for LabelValueEncoder<'a> {
463+
impl std::fmt::Write for LabelValueEncoder<'_> {
464464
fn write_str(&mut self, s: &str) -> std::fmt::Result {
465465
for_both_mut!(self, LabelValueEncoderInner, e, e.write_str(s))
466466
}
@@ -485,7 +485,7 @@ impl EncodeLabelValue for &String {
485485
}
486486
}
487487

488-
impl<'a> EncodeLabelValue for Cow<'a, str> {
488+
impl EncodeLabelValue for Cow<'_, str> {
489489
fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> {
490490
EncodeLabelValue::encode(&self.as_ref(), encoder)
491491
}
@@ -610,7 +610,7 @@ enum GaugeValueEncoderInner<'a> {
610610
Protobuf(protobuf::GaugeValueEncoder<'a>),
611611
}
612612

613-
impl<'a> GaugeValueEncoder<'a> {
613+
impl GaugeValueEncoder<'_> {
614614
fn encode_u32(&mut self, v: u32) -> Result<(), std::fmt::Error> {
615615
for_both_mut!(self, GaugeValueEncoderInner, e, e.encode_u32(v))
616616
}
@@ -678,7 +678,7 @@ enum CounterValueEncoderInner<'a> {
678678
Protobuf(protobuf::CounterValueEncoder<'a>),
679679
}
680680

681-
impl<'a> CounterValueEncoder<'a> {
681+
impl CounterValueEncoder<'_> {
682682
fn encode_f64(&mut self, v: f64) -> Result<(), std::fmt::Error> {
683683
for_both_mut!(self, CounterValueEncoderInner, e, e.encode_f64(v))
684684
}
@@ -742,7 +742,7 @@ enum ExemplarValueEncoderInner<'a> {
742742
Protobuf(protobuf::ExemplarValueEncoder<'a>),
743743
}
744744

745-
impl<'a> ExemplarValueEncoder<'a> {
745+
impl ExemplarValueEncoder<'_> {
746746
fn encode(&mut self, v: f64) -> Result<(), std::fmt::Error> {
747747
for_both_mut!(self, ExemplarValueEncoderInner, e, e.encode(v))
748748
}

src/encoding/protobuf.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub(crate) struct GaugeValueEncoder<'a> {
322322
value: &'a mut openmetrics_data_model::gauge_value::Value,
323323
}
324324

325-
impl<'a> GaugeValueEncoder<'a> {
325+
impl GaugeValueEncoder<'_> {
326326
pub fn encode_u32(&mut self, v: u32) -> Result<(), std::fmt::Error> {
327327
self.encode_i64(v as i64)
328328
}
@@ -343,7 +343,7 @@ pub(crate) struct ExemplarValueEncoder<'a> {
343343
value: &'a mut f64,
344344
}
345345

346-
impl<'a> ExemplarValueEncoder<'a> {
346+
impl ExemplarValueEncoder<'_> {
347347
pub fn encode(&mut self, v: f64) -> Result<(), std::fmt::Error> {
348348
*self.value = v;
349349
Ok(())
@@ -364,7 +364,7 @@ pub(crate) struct CounterValueEncoder<'a> {
364364
value: &'a mut openmetrics_data_model::counter_value::Total,
365365
}
366366

367-
impl<'a> CounterValueEncoder<'a> {
367+
impl CounterValueEncoder<'_> {
368368
pub fn encode_f64(&mut self, v: f64) -> Result<(), std::fmt::Error> {
369369
*self.value = openmetrics_data_model::counter_value::Total::DoubleValue(v);
370370
Ok(())
@@ -381,7 +381,7 @@ pub(crate) struct LabelSetEncoder<'a> {
381381
labels: &'a mut Vec<openmetrics_data_model::Label>,
382382
}
383383

384-
impl<'a> LabelSetEncoder<'a> {
384+
impl LabelSetEncoder<'_> {
385385
pub fn encode_label(&mut self) -> LabelEncoder {
386386
LabelEncoder {
387387
labels: self.labels,
@@ -394,7 +394,7 @@ pub(crate) struct LabelEncoder<'a> {
394394
labels: &'a mut Vec<openmetrics_data_model::Label>,
395395
}
396396

397-
impl<'a> LabelEncoder<'a> {
397+
impl LabelEncoder<'_> {
398398
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
399399
self.labels.push(openmetrics_data_model::Label::default());
400400

@@ -409,7 +409,7 @@ pub(crate) struct LabelKeyEncoder<'a> {
409409
label: &'a mut openmetrics_data_model::Label,
410410
}
411411

412-
impl<'a> std::fmt::Write for LabelKeyEncoder<'a> {
412+
impl std::fmt::Write for LabelKeyEncoder<'_> {
413413
fn write_str(&mut self, s: &str) -> std::fmt::Result {
414414
self.label.name.write_str(s)
415415
}
@@ -428,13 +428,13 @@ pub(crate) struct LabelValueEncoder<'a> {
428428
label_value: &'a mut String,
429429
}
430430

431-
impl<'a> LabelValueEncoder<'a> {
431+
impl LabelValueEncoder<'_> {
432432
pub fn finish(self) -> Result<(), std::fmt::Error> {
433433
Ok(())
434434
}
435435
}
436436

437-
impl<'a> std::fmt::Write for LabelValueEncoder<'a> {
437+
impl std::fmt::Write for LabelValueEncoder<'_> {
438438
fn write_str(&mut self, s: &str) -> std::fmt::Result {
439439
self.label_value.write_str(s)
440440
}

src/encoding/text.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub(crate) struct DescriptorEncoder<'a> {
188188
labels: &'a [(Cow<'static, str>, Cow<'static, str>)],
189189
}
190190

191-
impl<'a> std::fmt::Debug for DescriptorEncoder<'a> {
191+
impl std::fmt::Debug for DescriptorEncoder<'_> {
192192
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
193193
f.debug_struct("DescriptorEncoder").finish()
194194
}
@@ -293,7 +293,7 @@ pub(crate) struct MetricEncoder<'a> {
293293
family_labels: Option<&'a dyn super::EncodeLabelSet>,
294294
}
295295

296-
impl<'a> std::fmt::Debug for MetricEncoder<'a> {
296+
impl std::fmt::Debug for MetricEncoder<'_> {
297297
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
298298
let mut labels = String::new();
299299
if let Some(l) = self.family_labels {
@@ -310,7 +310,7 @@ impl<'a> std::fmt::Debug for MetricEncoder<'a> {
310310
}
311311
}
312312

313-
impl<'a> MetricEncoder<'a> {
313+
impl MetricEncoder<'_> {
314314
pub fn encode_counter<
315315
S: EncodeLabelSet,
316316
CounterValue: super::EncodeCounterValue,
@@ -555,13 +555,13 @@ pub(crate) struct CounterValueEncoder<'a> {
555555
writer: &'a mut dyn Write,
556556
}
557557

558-
impl<'a> std::fmt::Debug for CounterValueEncoder<'a> {
558+
impl std::fmt::Debug for CounterValueEncoder<'_> {
559559
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
560560
f.debug_struct("CounterValueEncoder").finish()
561561
}
562562
}
563563

564-
impl<'a> CounterValueEncoder<'a> {
564+
impl CounterValueEncoder<'_> {
565565
pub fn encode_f64(&mut self, v: f64) -> Result<(), std::fmt::Error> {
566566
self.writer.write_str(" ")?;
567567
self.writer.write_str(dtoa::Buffer::new().format(v))?;
@@ -579,13 +579,13 @@ pub(crate) struct GaugeValueEncoder<'a> {
579579
writer: &'a mut dyn Write,
580580
}
581581

582-
impl<'a> std::fmt::Debug for GaugeValueEncoder<'a> {
582+
impl std::fmt::Debug for GaugeValueEncoder<'_> {
583583
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
584584
f.debug_struct("GaugeValueEncoder").finish()
585585
}
586586
}
587587

588-
impl<'a> GaugeValueEncoder<'a> {
588+
impl GaugeValueEncoder<'_> {
589589
pub fn encode_u32(&mut self, v: u32) -> Result<(), std::fmt::Error> {
590590
self.writer.write_str(" ")?;
591591
self.writer.write_str(itoa::Buffer::new().format(v))?;
@@ -609,13 +609,13 @@ pub(crate) struct ExemplarValueEncoder<'a> {
609609
writer: &'a mut dyn Write,
610610
}
611611

612-
impl<'a> std::fmt::Debug for ExemplarValueEncoder<'a> {
612+
impl std::fmt::Debug for ExemplarValueEncoder<'_> {
613613
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
614614
f.debug_struct("ExemplarValueEncoder").finish()
615615
}
616616
}
617617

618-
impl<'a> ExemplarValueEncoder<'a> {
618+
impl ExemplarValueEncoder<'_> {
619619
pub fn encode(&mut self, v: f64) -> Result<(), std::fmt::Error> {
620620
self.writer.write_str(dtoa::Buffer::new().format(v))
621621
}
@@ -626,7 +626,7 @@ pub(crate) struct LabelSetEncoder<'a> {
626626
first: bool,
627627
}
628628

629-
impl<'a> std::fmt::Debug for LabelSetEncoder<'a> {
629+
impl std::fmt::Debug for LabelSetEncoder<'_> {
630630
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
631631
f.debug_struct("LabelSetEncoder")
632632
.field("first", &self.first)
@@ -657,15 +657,15 @@ pub(crate) struct LabelEncoder<'a> {
657657
first: bool,
658658
}
659659

660-
impl<'a> std::fmt::Debug for LabelEncoder<'a> {
660+
impl std::fmt::Debug for LabelEncoder<'_> {
661661
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
662662
f.debug_struct("LabelEncoder")
663663
.field("first", &self.first)
664664
.finish()
665665
}
666666
}
667667

668-
impl<'a> LabelEncoder<'a> {
668+
impl LabelEncoder<'_> {
669669
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
670670
if !self.first {
671671
self.writer.write_str(",")?;
@@ -680,7 +680,7 @@ pub(crate) struct LabelKeyEncoder<'a> {
680680
writer: &'a mut dyn Write,
681681
}
682682

683-
impl<'a> std::fmt::Debug for LabelKeyEncoder<'a> {
683+
impl std::fmt::Debug for LabelKeyEncoder<'_> {
684684
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
685685
f.debug_struct("LabelKeyEncoder").finish()
686686
}
@@ -695,7 +695,7 @@ impl<'a> LabelKeyEncoder<'a> {
695695
}
696696
}
697697

698-
impl<'a> std::fmt::Write for LabelKeyEncoder<'a> {
698+
impl std::fmt::Write for LabelKeyEncoder<'_> {
699699
fn write_str(&mut self, s: &str) -> std::fmt::Result {
700700
self.writer.write_str(s)
701701
}
@@ -705,19 +705,19 @@ pub(crate) struct LabelValueEncoder<'a> {
705705
writer: &'a mut dyn Write,
706706
}
707707

708-
impl<'a> std::fmt::Debug for LabelValueEncoder<'a> {
708+
impl std::fmt::Debug for LabelValueEncoder<'_> {
709709
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
710710
f.debug_struct("LabelValueEncoder").finish()
711711
}
712712
}
713713

714-
impl<'a> LabelValueEncoder<'a> {
714+
impl LabelValueEncoder<'_> {
715715
pub fn finish(self) -> Result<(), std::fmt::Error> {
716716
self.writer.write_str("\"")
717717
}
718718
}
719719

720-
impl<'a> std::fmt::Write for LabelValueEncoder<'a> {
720+
impl std::fmt::Write for LabelValueEncoder<'_> {
721721
fn write_str(&mut self, s: &str) -> std::fmt::Result {
722722
self.writer.write_str(s)
723723
}

0 commit comments

Comments
 (0)