Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): fix clippy warnings when using rust 1.83 #250

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ prost-types = { version = "0.12.0", optional = true }
async-std = { version = "1", features = ["attributes"] }
axum = "0.7"
criterion = "0.5"
futures = "0.3"
http-types = "2"
pyo3 = "0.22"
quickcheck = "1"
Expand Down
6 changes: 2 additions & 4 deletions examples/hyper.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use futures::future::BoxFuture;
use http_body_util::{combinators, BodyExt, Full};
use hyper::{
body::{Bytes, Incoming},
Expand All @@ -8,10 +9,8 @@ use hyper::{
use hyper_util::rt::TokioIo;
use prometheus_client::{encoding::text::encode, metrics::counter::Counter, registry::Registry};
use std::{
future::Future,
io,
net::{IpAddr, Ipv4Addr, SocketAddr},
pin::Pin,
sync::Arc,
};
use tokio::{
Expand Down Expand Up @@ -69,8 +68,7 @@ type BoxBody = combinators::BoxBody<Bytes, hyper::Error>;
/// This function returns a HTTP handler (i.e. another function)
pub fn make_handler(
registry: Arc<Registry>,
) -> impl Fn(Request<Incoming>) -> Pin<Box<dyn Future<Output = io::Result<Response<BoxBody>>> + Send>>
{
) -> impl Fn(Request<Incoming>) -> BoxFuture<'static, io::Result<Response<BoxBody>>> {
// This closure accepts a request and responds with the OpenMetrics encoding of our metrics.
move |_req: Request<Incoming>| {
let reg = registry.clone();
Expand Down
20 changes: 10 additions & 10 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl<'a> From<protobuf::LabelSetEncoder<'a>> for LabelSetEncoder<'a> {
}
}

impl<'a> LabelSetEncoder<'a> {
impl LabelSetEncoder<'_> {
/// Encode the given label.
pub fn encode_label(&mut self) -> LabelEncoder {
for_both_mut!(self, LabelSetEncoderInner, e, e.encode_label().into())
Expand Down Expand Up @@ -271,7 +271,7 @@ impl<'a> From<protobuf::LabelEncoder<'a>> for LabelEncoder<'a> {
}
}

impl<'a> LabelEncoder<'a> {
impl LabelEncoder<'_> {
/// Encode a label.
pub fn encode_label_key(&mut self) -> Result<LabelKeyEncoder, std::fmt::Error> {
for_both_mut!(
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<'a> From<protobuf::LabelKeyEncoder<'a>> for LabelKeyEncoder<'a> {
}
}

impl<'a> std::fmt::Write for LabelKeyEncoder<'a> {
impl std::fmt::Write for LabelKeyEncoder<'_> {
fn write_str(&mut self, s: &str) -> std::fmt::Result {
for_both_mut!(self, LabelKeyEncoderInner, e, e.write_str(s))
}
Expand Down Expand Up @@ -390,7 +390,7 @@ impl EncodeLabelKey for String {
}
}

impl<'a> EncodeLabelKey for Cow<'a, str> {
impl EncodeLabelKey for Cow<'_, str> {
fn encode(&self, encoder: &mut LabelKeyEncoder) -> Result<(), std::fmt::Error> {
EncodeLabelKey::encode(&self.as_ref(), encoder)
}
Expand Down Expand Up @@ -453,14 +453,14 @@ enum LabelValueEncoderInner<'a> {
Protobuf(protobuf::LabelValueEncoder<'a>),
}

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

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

impl<'a> EncodeLabelValue for Cow<'a, str> {
impl EncodeLabelValue for Cow<'_, str> {
fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> {
EncodeLabelValue::encode(&self.as_ref(), encoder)
}
Expand Down Expand Up @@ -610,7 +610,7 @@ enum GaugeValueEncoderInner<'a> {
Protobuf(protobuf::GaugeValueEncoder<'a>),
}

impl<'a> GaugeValueEncoder<'a> {
impl GaugeValueEncoder<'_> {
fn encode_u32(&mut self, v: u32) -> Result<(), std::fmt::Error> {
for_both_mut!(self, GaugeValueEncoderInner, e, e.encode_u32(v))
}
Expand Down Expand Up @@ -678,7 +678,7 @@ enum CounterValueEncoderInner<'a> {
Protobuf(protobuf::CounterValueEncoder<'a>),
}

impl<'a> CounterValueEncoder<'a> {
impl CounterValueEncoder<'_> {
fn encode_f64(&mut self, v: f64) -> Result<(), std::fmt::Error> {
for_both_mut!(self, CounterValueEncoderInner, e, e.encode_f64(v))
}
Expand Down Expand Up @@ -742,7 +742,7 @@ enum ExemplarValueEncoderInner<'a> {
Protobuf(protobuf::ExemplarValueEncoder<'a>),
}

impl<'a> ExemplarValueEncoder<'a> {
impl ExemplarValueEncoder<'_> {
fn encode(&mut self, v: f64) -> Result<(), std::fmt::Error> {
for_both_mut!(self, ExemplarValueEncoderInner, e, e.encode(v))
}
Expand Down
16 changes: 8 additions & 8 deletions src/encoding/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pub(crate) struct GaugeValueEncoder<'a> {
value: &'a mut openmetrics_data_model::gauge_value::Value,
}

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

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

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

impl<'a> LabelSetEncoder<'a> {
impl LabelSetEncoder<'_> {
pub fn encode_label(&mut self) -> LabelEncoder {
LabelEncoder {
labels: self.labels,
Expand All @@ -394,7 +394,7 @@ pub(crate) struct LabelEncoder<'a> {
labels: &'a mut Vec<openmetrics_data_model::Label>,
}

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

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

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

impl<'a> LabelValueEncoder<'a> {
impl LabelValueEncoder<'_> {
pub fn finish(self) -> Result<(), std::fmt::Error> {
Ok(())
}
}

impl<'a> std::fmt::Write for LabelValueEncoder<'a> {
impl std::fmt::Write for LabelValueEncoder<'_> {
fn write_str(&mut self, s: &str) -> std::fmt::Result {
self.label_value.write_str(s)
}
Expand Down
34 changes: 17 additions & 17 deletions src/encoding/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub(crate) struct DescriptorEncoder<'a> {
labels: &'a [(Cow<'static, str>, Cow<'static, str>)],
}

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

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

impl<'a> MetricEncoder<'a> {
impl MetricEncoder<'_> {
pub fn encode_counter<
S: EncodeLabelSet,
CounterValue: super::EncodeCounterValue,
Expand Down Expand Up @@ -555,13 +555,13 @@ pub(crate) struct CounterValueEncoder<'a> {
writer: &'a mut dyn Write,
}

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

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

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

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

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

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

impl<'a> std::fmt::Debug for LabelSetEncoder<'a> {
impl std::fmt::Debug for LabelSetEncoder<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LabelSetEncoder")
.field("first", &self.first)
Expand Down Expand Up @@ -657,15 +657,15 @@ pub(crate) struct LabelEncoder<'a> {
first: bool,
}

impl<'a> std::fmt::Debug for LabelEncoder<'a> {
impl std::fmt::Debug for LabelEncoder<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LabelEncoder")
.field("first", &self.first)
.finish()
}
}

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

impl<'a> std::fmt::Debug for LabelKeyEncoder<'a> {
impl std::fmt::Debug for LabelKeyEncoder<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("LabelKeyEncoder").finish()
}
Expand All @@ -695,7 +695,7 @@ impl<'a> LabelKeyEncoder<'a> {
}
}

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

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

impl<'a> LabelValueEncoder<'a> {
impl LabelValueEncoder<'_> {
pub fn finish(self) -> Result<(), std::fmt::Error> {
self.writer.write_str("\"")
}
}

impl<'a> std::fmt::Write for LabelValueEncoder<'a> {
impl std::fmt::Write for LabelValueEncoder<'_> {
fn write_str(&mut self, s: &str) -> std::fmt::Result {
self.writer.write_str(s)
}
Expand Down
Loading