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

fix(common): clippy issues raised by 1.63 #862

Merged
merged 5 commits into from
Aug 14, 2022
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ jobs:
profile: minimal
toolchain: 1.49
override: true
- name: Prepare minimal package versions
run: cargo update -p serde --precise 1.0.142
- name: Run tests
run: cargo --version &&
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,rt-tokio,testing &&
Expand Down
1 change: 1 addition & 0 deletions examples/grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl<'a> Injector for MetadataMap<'a> {
}
}

#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld");
}
Expand Down
1 change: 1 addition & 0 deletions examples/grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use opentelemetry::{
};
use std::error::Error;

#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld"); // The string specified here must match the proto package name.
}
Expand Down
1 change: 1 addition & 0 deletions examples/tracing-grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl<'a> Injector for MetadataMap<'a> {
}
}

#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld");
}
Expand Down
1 change: 1 addition & 0 deletions examples/tracing-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use tracing::*;
use tracing_opentelemetry::OpenTelemetrySpanExt;
use tracing_subscriber::prelude::*;

#[allow(clippy::derive_partial_eq_without_eq)] // tonic don't derive Eq for generated types. We shouldn't manually change it.
pub mod hello_world {
tonic::include_proto!("helloworld"); // The string specified here must match the proto package name
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/baggage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl BaggageExt for Context {
/// `BaggageMetadata` can be added to values in the form of a property set,
/// represented as semi-colon `;` delimited list of names and/or name/value
/// pairs, e.g. `;k1=v1;k2;k3=v3`.
#[derive(Clone, Debug, PartialOrd, PartialEq, Default)]
#[derive(Clone, Debug, PartialOrd, PartialEq, Eq, Default)]
pub struct BaggageMetadata(String);

impl BaggageMetadata {
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub enum Value {
}

/// Wrapper for string-like values
#[derive(Clone, PartialEq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct StringValue(OtelString);

impl fmt::Debug for StringValue {
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-api/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Context {
pub fn get<T: 'static>(&self) -> Option<&T> {
self.entries
.get(&TypeId::of::<T>())
.and_then(|rc| (&*rc).downcast_ref())
.and_then(|rc| rc.downcast_ref())
}

/// Returns a copy of the context with the new value included.
Expand Down Expand Up @@ -324,8 +324,8 @@ impl Drop for ContextGuard {
/// while the context is still borrowed.
fn get_current<F: FnMut(&Context) -> T, T>(mut f: F) -> T {
CURRENT_CONTEXT
.try_with(|cx| f(&*cx.borrow()))
.unwrap_or_else(|_| DEFAULT_CONTEXT.with(|cx| f(&*cx)))
.try_with(|cx| f(&cx.borrow()))
.unwrap_or_else(|_| DEFAULT_CONTEXT.with(|cx| f(cx)))
}

/// With TypeIds as keys, there's no need to hash them. They are already hashes
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<T> From<PoisonError<T>> for MetricsError {
}

/// Units denote underlying data units tracked by `Meter`s.
#[derive(Clone, Default, Debug, PartialEq, Hash)]
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
pub struct Unit(Cow<'static, str>);

impl Unit {
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-api/src/trace/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl SpanRef<'_> {
fn with_inner_mut<F: FnOnce(&mut global::BoxedSpan)>(&self, f: F) {
if let Some(ref inner) = self.0.inner {
match inner.lock() {
Ok(mut locked) => f(&mut *locked),
Ok(mut locked) => f(&mut locked),
Err(err) => global::handle_error(err),
}
}
Expand Down Expand Up @@ -269,7 +269,7 @@ impl TraceContextExt for Context {
if let Some(span) = self.get::<SynchronizedSpan>() {
SpanRef(span)
} else {
SpanRef(&*NOOP_SPAN)
SpanRef(&NOOP_SPAN)
}
}

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/trace/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub trait Span {
/// | `Producer` | | yes | | maybe |
/// | `Consumer` | | yes | maybe | |
/// | `Internal` | | | | |
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SpanKind {
/// Indicates that the span describes a request to some remote service. This
/// span is usually the parent of a remote `SpanKind::Server` span and does
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub struct SamplingResult {
}

/// Decision about whether or not to sample
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SamplingDecision {
/// Span will not be recorded and all events and attributes will be dropped.
Drop,
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-jaeger/src/exporter/config/collector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,16 @@ impl CollectorPipeline {
/// If users uses custom http client. This function can help retrieve the value of
/// `OTEL_EXPORTER_JAEGER_USER` environment variable.
pub fn collector_username(&self) -> Option<String> {
(&self.collector_username).clone()
self.collector_username.clone()
}

/// Get the collector's password set in the builder. Default to be the value of
/// `OTEL_EXPORTER_JAEGER_PASSWORD` environment variable.
///
/// If users uses custom http client. This function can help retrieve the value of
/// `OTEL_EXPORTER_JAEGER_PASSWORD` environment variable.
pub fn collector_password(self) -> Option<String> {
(&self.collector_password).clone()
pub fn collector_password(&self) -> Option<String> {
self.collector_password.clone()
}

/// Custom http client used to send spans.
Expand Down
7 changes: 4 additions & 3 deletions opentelemetry-jaeger/src/testing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[allow(unused, missing_docs)]
#[allow(unused, missing_docs, clippy::derive_partial_eq_without_eq)]
// tonic don't derive Eq. We shouldn't manually change it.)]
pub mod jaeger_api_v2;

#[allow(missing_docs)]
Expand Down Expand Up @@ -48,7 +49,7 @@ pub mod jaeger_client {
.await
.unwrap();

return if let Some(spans) = resp
if let Some(spans) = resp
.get_mut()
.message()
.await
Expand All @@ -57,7 +58,7 @@ pub mod jaeger_client {
spans.spans
} else {
vec![]
};
}
}

/// Find traces belongs the service.
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/metric.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! OTEL metric exporter
//!
//! Defines a [Exporter] to send metric data to backend via OTEL protocol.
//! Defines a [MetricsExporter] to send metric data to backend via OTEL protocol.
//!
//! Currently, OTEL metrics exporter only support GRPC connection via tonic on tokio runtime.

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-proto/src/transform/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub mod tonic {

use opentelemetry::{Key, Value};

/// Convert [`Number`](opentelemetry::metrics::Number) to target type based
/// on it's [`NumberKind`](opentelemetry::metrics::NumberKind).
/// Convert [`Number`](opentelemetry::sdk::metrics::sdk_api::Number) to target type based
/// on it's [`NumberKind`](opentelemetry::sdk::metrics::sdk_api::NumberKind).
pub trait FromNumber {
fn from_number(number: Number, number_kind: &NumberKind) -> Self;
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/export/metrics/aggregation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait Histogram: Sum + Count + Aggregation {
/// For example, test for a Histogram before testing for a Sum, and so on.
///
/// [`Aggregator`]: crate::metrics::aggregators::Aggregator
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AggregationKind(&'static str);

impl AggregationKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl TemporalitySelector for StatelessTemporalitySelector {

/// Temporality indicates the temporal aggregation exported by an exporter.
/// These bits may be OR-d together when multiple exporters are in use.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Temporality {
/// Indicates that an Exporter expects a Cumulative Aggregation.
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/sdk_api/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::hash::{Hash, Hasher};

/// Descriptor contains all the settings that describe an instrument, including
/// its name, metric kind, number kind, and the configurable options.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Descriptor {
name: String,
instrument_kind: InstrumentKind,
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/sdk_api/instrument_kind.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Kinds of OpenTelemetry metric instruments
#[derive(Clone, Debug, PartialEq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum InstrumentKind {
/// A histogram instrument
Histogram,
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/sdk_api/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl From<u64> for Number {
}

/// A descriptor for the encoded data type of a `Number`
#[derive(Clone, Debug, PartialEq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum NumberKind {
/// A Number that stores `i64` values.
I64,
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/trace/evicted_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::VecDeque;
/// This queue maintains an ordered list of elements, and a count of
/// dropped elements. Elements are removed from the queue in a first
/// in first out fashion.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EvictedQueue<T> {
queue: Option<VecDeque<T>>,
max_len: u32,
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-stackdriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use tonic::{
#[cfg(feature = "yup-authorizer")]
use yup_oauth2::authenticator::Authenticator;

#[allow(clippy::derive_partial_eq_without_eq)] // tonic doesn't derive Eq for generated types
pub mod proto;

use proto::devtools::cloudtrace::v2::BatchWriteSpansRequest;
Expand Down