Skip to content

Commit

Permalink
fix: all clippy errors introduced in rust 1.51.0 (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp committed Mar 26, 2021
1 parent 30849f2 commit b6d8494
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: -p opentelemetry -p opentelemetry-jaeger -p opentelemetry-zipkin -p opentelemetry-datadog -p opentelemetry-aws -p opentelemetry-stackdriver --all-features --no-fail-fast
args: -p opentelemetry -p opentelemetry-jaeger -p opentelemetry-zipkin -p opentelemetry-datadog -p opentelemetry-aws --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
Expand Down
11 changes: 7 additions & 4 deletions opentelemetry-aws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub mod trace {
},
Context,
};
use std::convert::{TryFrom, TryInto};

const AWS_XRAY_TRACE_HEADER: &str = "x-amzn-trace-id";
const AWS_XRAY_VERSION_KEY: &str = "1";
Expand Down Expand Up @@ -106,7 +107,7 @@ pub mod trace {
match key {
HEADER_ROOT_KEY => {
let converted_trace_id: Result<TraceId, ()> =
XrayTraceId(value.to_string()).into();
XrayTraceId(value.to_string()).try_into();
match converted_trace_id {
Err(_) => return Err(()),
Ok(parsed) => trace_id = parsed,
Expand Down Expand Up @@ -216,9 +217,11 @@ pub mod trace {
#[derive(Clone, Debug, PartialEq)]
struct XrayTraceId(String);

impl Into<Result<TraceId, ()>> for XrayTraceId {
fn into(self) -> Result<TraceId, ()> {
let parts: Vec<&str> = self.0.split_terminator('-').collect();
impl TryFrom<XrayTraceId> for TraceId {
type Error = ();

fn try_from(id: XrayTraceId) -> Result<Self, Self::Error> {
let parts: Vec<&str> = id.0.split_terminator('-').collect();

if parts.len() != 3 {
return Err(());
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-jaeger/src/exporter/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl fmt::Debug for BufferClient {
/// `AgentAsyncClientUDP` implements an async version of the `TAgentSyncClient`
/// interface over UDP.
#[derive(Debug)]
pub(crate) struct AgentAsyncClientUDP {
pub(crate) struct AgentAsyncClientUdp {
#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
conn: UdpSocket,
#[cfg(feature = "tokio")]
Expand All @@ -46,7 +46,7 @@ pub(crate) struct AgentAsyncClientUDP {
max_packet_size: usize,
}

impl AgentAsyncClientUDP {
impl AgentAsyncClientUdp {
/// Create a new UDP agent client
pub(crate) fn new<T: ToSocketAddrs>(
host_port: T,
Expand All @@ -62,7 +62,7 @@ impl AgentAsyncClientUDP {
let conn = UdpSocket::bind("0.0.0.0:0")?;
conn.connect(host_port)?;

Ok(AgentAsyncClientUDP {
Ok(AgentAsyncClientUdp {
#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
conn,
#[cfg(feature = "tokio")]
Expand Down Expand Up @@ -100,21 +100,21 @@ impl AgentAsyncClientUDP {
}

#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
async fn write_to_socket(client: &mut AgentAsyncClientUDP, payload: Vec<u8>) -> thrift::Result<()> {
async fn write_to_socket(client: &mut AgentAsyncClientUdp, payload: Vec<u8>) -> thrift::Result<()> {
client.conn.send(&payload)?;

Ok(())
}

#[cfg(feature = "tokio")]
async fn write_to_socket(client: &mut AgentAsyncClientUDP, payload: Vec<u8>) -> thrift::Result<()> {
async fn write_to_socket(client: &mut AgentAsyncClientUdp, payload: Vec<u8>) -> thrift::Result<()> {
client.conn.send(&payload).await?;

Ok(())
}

#[cfg(all(feature = "async-std", not(feature = "tokio")))]
async fn write_to_socket(client: &mut AgentAsyncClientUDP, payload: Vec<u8>) -> thrift::Result<()> {
async fn write_to_socket(client: &mut AgentAsyncClientUdp, payload: Vec<u8>) -> thrift::Result<()> {
client.conn.send(&payload).await?;

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-jaeger/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) mod transport;
mod uploader;

use self::thrift::jaeger;
use agent::AgentAsyncClientUDP;
use agent::AgentAsyncClientUdp;
use async_trait::async_trait;
#[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))]
use collector::CollectorAsyncClientHttp;
Expand Down Expand Up @@ -321,7 +321,7 @@ impl PipelineBuilder {

#[cfg(not(any(feature = "collector_client", feature = "wasm_collector_client")))]
fn init_uploader(self) -> Result<(Process, BatchUploader), TraceError> {
let agent = AgentAsyncClientUDP::new(self.agent_endpoint.as_slice(), self.max_packet_size)
let agent = AgentAsyncClientUdp::new(self.agent_endpoint.as_slice(), self.max_packet_size)
.map_err::<Error, _>(Into::into)?;
Ok((self.process, BatchUploader::Agent(agent)))
}
Expand Down Expand Up @@ -413,7 +413,7 @@ impl PipelineBuilder {
Ok((self.process, uploader::BatchUploader::Collector(collector)))
} else {
let endpoint = self.agent_endpoint.as_slice();
let agent = AgentAsyncClientUDP::new(endpoint, self.max_packet_size)
let agent = AgentAsyncClientUdp::new(endpoint, self.max_packet_size)
.map_err::<Error, _>(Into::into)?;
Ok((self.process, BatchUploader::Agent(agent)))
}
Expand All @@ -435,7 +435,7 @@ impl PipelineBuilder {
Ok((self.process, uploader::BatchUploader::Collector(collector)))
} else {
let endpoint = self.agent_endpoint.as_slice();
let agent = AgentAsyncClientUDP::new(endpoint, self.max_packet_size)
let agent = AgentAsyncClientUdp::new(endpoint, self.max_packet_size)
.map_err::<Error, _>(Into::into)?;
Ok((self.process, BatchUploader::Agent(agent)))
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/src/exporter/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use opentelemetry::sdk::export::trace;
#[derive(Debug)]
pub(crate) enum BatchUploader {
/// Agent sync client
Agent(agent::AgentAsyncClientUDP),
Agent(agent::AgentAsyncClientUdp),
/// Collector sync client
#[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))]
Collector(collector::CollectorAsyncClientHttp),
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/common.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/metrics_service.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/resource.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/trace.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/trace_config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/proto/grpcio/trace_service.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file is generated by rust-protobuf 2.22.0. Do not edit
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ pub enum Compression {
}

#[cfg(feature = "grpc-sys")]
impl Into<grpcio::CompressionAlgorithms> for Compression {
fn into(self) -> grpcio::CompressionAlgorithms {
match self {
impl From<Compression> for grpcio::CompressionAlgorithms {
fn from(compression: Compression) -> Self {
match compression {
Compression::Gzip => grpcio::CompressionAlgorithms::GRPC_COMPRESS_GZIP,
}
}
Expand Down
10 changes: 5 additions & 5 deletions opentelemetry/benches/ddsketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use opentelemetry::{
metrics::Descriptor,
sdk::{
export::metrics::Quantile,
metrics::aggregators::{ArrayAggregator, DDSKetchAggregator, DDSketchConfig},
metrics::aggregators::{ArrayAggregator, DdSketchAggregator, DdSketchConfig},
},
};
use rand::Rng;
Expand All @@ -25,7 +25,7 @@ fn get_test_quantile() -> &'static [f64] {

fn ddsketch(data: Vec<f64>) {
let aggregator =
DDSKetchAggregator::new(&DDSketchConfig::new(0.001, 2048, 1e-9), NumberKind::F64);
DdSketchAggregator::new(&DdSketchConfig::new(0.001, 2048, 1e-9), NumberKind::F64);
let descriptor = Descriptor::new(
"test".to_string(),
"test",
Expand All @@ -36,15 +36,15 @@ fn ddsketch(data: Vec<f64>) {
for f in data {
aggregator.update(&Number::from(f), &descriptor).unwrap();
}
let new_aggregator: Arc<(dyn Aggregator + Send + Sync)> = Arc::new(DDSKetchAggregator::new(
&DDSketchConfig::new(0.001, 2048, 1e-9),
let new_aggregator: Arc<(dyn Aggregator + Send + Sync)> = Arc::new(DdSketchAggregator::new(
&DdSketchConfig::new(0.001, 2048, 1e-9),
NumberKind::F64,
));
aggregator
.synchronized_move(&new_aggregator, &descriptor)
.unwrap();
for quantile in get_test_quantile() {
if let Some(new_aggregator) = new_aggregator.as_any().downcast_ref::<DDSKetchAggregator>() {
if let Some(new_aggregator) = new_aggregator.as_any().downcast_ref::<DdSketchAggregator>() {
let _ = new_aggregator.quantile(*quantile);
}
}
Expand Down

0 comments on commit b6d8494

Please sign in to comment.