Skip to content

Commit b15b119

Browse files
authored
chore: fix clippy's awful new "inconsistent struct constructor" lint (#1401)
This branch fixes some annoying new clippy lints no one cares about. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
1 parent b6c07e7 commit b15b119

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

tracing-attributes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ impl Parse for Field {
807807
} else {
808808
None
809809
};
810-
Ok(Self { name, kind, value })
810+
Ok(Self { name, value, kind })
811811
}
812812
}
813813

tracing-core/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ impl<'a> Event<'a> {
4141
#[inline]
4242
pub fn new(metadata: &'static Metadata<'static>, fields: &'a field::ValueSet<'a>) -> Self {
4343
Event {
44-
metadata,
4544
fields,
45+
metadata,
4646
parent: Parent::Current,
4747
}
4848
}
@@ -60,8 +60,8 @@ impl<'a> Event<'a> {
6060
None => Parent::Root,
6161
};
6262
Event {
63-
metadata,
6463
fields,
64+
metadata,
6565
parent,
6666
}
6767
}

tracing-subscriber/src/subscribe.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,7 @@ impl<'a, C> Context<'a, C> {
11191119
impl<'a, C> Clone for Context<'a, C> {
11201120
#[inline]
11211121
fn clone(&self) -> Self {
1122-
let subscriber = if let Some(ref subscriber) = self.subscriber {
1123-
Some(*subscriber)
1124-
} else {
1125-
None
1126-
};
1122+
let subscriber = self.subscriber.as_ref().copied();
11271123
Context { subscriber }
11281124
}
11291125
}
@@ -1258,7 +1254,7 @@ pub(crate) mod tests {
12581254
.and_then(NopSubscriber)
12591255
.with_collector(StringCollector("collector".into()));
12601256
let collector =
1261-
Collect::downcast_ref::<StringCollector>(&s).expect("collector should downcast");
1257+
<dyn Collect>::downcast_ref::<StringCollector>(&s).expect("collector should downcast");
12621258
assert_eq!(&collector.0, "collector");
12631259
}
12641260

tracing-tower/src/service_span.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mod layer {
5757

5858
fn layer(&self, inner: S) -> Self::Service {
5959
let span = self.get_span.span_for(&inner);
60-
Service { span, inner }
60+
Service { inner, span }
6161
}
6262
}
6363

@@ -221,7 +221,7 @@ pub mod make {
221221

222222
impl<S> Service<S> {
223223
pub fn new(inner: S, span: tracing::Span) -> Self {
224-
Self { span, inner }
224+
Self { inner, span }
225225
}
226226
}
227227

0 commit comments

Comments
 (0)