Skip to content

Commit 986c68d

Browse files
silvanshadehawkw
authored andcommitted
ci: run clippy-check action on CI (#491)
This is a follow up PR for #477 that runs clippy on CI. * Switch from hecrj/setup-rust-action to actions-rs/toolchain * Fix remaining clippy lints * Switch to minimal rustup profile * Replace warning step with clippy * Remove #![feature(async_await)]
1 parent eaa9317 commit 986c68d

File tree

11 files changed

+33
-88
lines changed

11 files changed

+33
-88
lines changed

.github/workflows/CI.yml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ jobs:
1010
matrix:
1111
rust: [stable, 1.39.0]
1212
steps:
13-
- uses: hecrj/setup-rust-action@v1
13+
- uses: actions-rs/toolchain@v1
1414
with:
15-
rust-version: ${{ matrix.rust }}
15+
toolchain: ${{ matrix.rust }}
16+
profile: minimal
1617
- uses: actions/checkout@master
1718
- name: Check
1819
run: cargo check --all --bins --examples --tests --benches
@@ -100,9 +101,10 @@ jobs:
100101
matrix:
101102
rust: [stable, beta, nightly, 1.39.0]
102103
steps:
103-
- uses: hecrj/setup-rust-action@v1
104+
- uses: actions-rs/toolchain@v1
104105
with:
105-
rust-version: ${{ matrix.rust }}
106+
toolchain: ${{ matrix.rust }}
107+
profile: minimal
106108
- uses: actions/checkout@master
107109
- name: Build
108110
run: cargo build
@@ -117,9 +119,10 @@ jobs:
117119
matrix:
118120
os: [ubuntu-latest, windows-latest, macOS-latest]
119121
steps:
120-
- uses: hecrj/setup-rust-action@v1
122+
- uses: actions-rs/toolchain@v1
121123
with:
122-
rust-version: stable
124+
toolchain: stable
125+
profile: minimal
123126
- uses: actions/checkout@master
124127
- name: Build
125128
run: cargo build
@@ -131,9 +134,10 @@ jobs:
131134
needs: check
132135
runs-on: ubuntu-latest
133136
steps:
134-
- uses: hecrj/setup-rust-action@v1
137+
- uses: actions-rs/toolchain@v1
135138
with:
136-
rust-version: stable
139+
toolchain: stable
140+
profile: minimal
137141
- uses: actions/checkout@master
138142
- name: "Test log support"
139143
run: (cd tracing/test-log-support && cargo test)
@@ -151,9 +155,10 @@ jobs:
151155
needs: check
152156
runs-on: ubuntu-latest
153157
steps:
154-
- uses: hecrj/setup-rust-action@v1
158+
- uses: actions-rs/toolchain@v1
155159
with:
156-
rust-version: nightly
160+
toolchain: nightly
161+
profile: minimal
157162
- uses: actions/checkout@master
158163
- name: "Test tracing-futures std::future support"
159164
run: (cd tracing-futures/test_std_future && cargo test)
@@ -169,21 +174,27 @@ jobs:
169174
needs: check
170175
runs-on: ubuntu-latest
171176
steps:
172-
- uses: hecrj/setup-rust-action@v1
177+
- uses: actions-rs/toolchain@v1
173178
with:
174-
rust-version: stable
179+
toolchain: stable
180+
components: rustfmt
181+
profile: minimal
175182
- uses: actions/checkout@master
176183
- name: rustfmt
177184
run: cargo fmt --all -- --check
178185

179186
warnings:
180187
# Check for any warnings. This is informational and thus is allowed to fail.
181-
needs: check
182188
runs-on: ubuntu-latest
183189
steps:
184-
- uses: hecrj/setup-rust-action@v1
190+
- uses: actions-rs/toolchain@v1
185191
with:
186-
rust-version: stable
192+
toolchain: stable
193+
components: clippy
194+
profile: minimal
187195
- uses: actions/checkout@master
188-
- name: warnings
189-
run: RUSTFLAGS="-Dwarnings" cargo check --all
196+
- name: Clippy
197+
uses: actions-rs/clippy-check@v1
198+
with:
199+
token: ${{ secrets.GITHUB_TOKEN }}
200+
args: --all --bins --examples --tests --benches -- -D warnings

tracing-attributes/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ use syn::{
9595
/// tracing::info!("inside my_function!");
9696
/// // ...
9797
/// }
98-
/// # fn main() {}
9998
/// ```
10099
/// Setting the level for the generated span:
101100
/// ```
@@ -104,7 +103,6 @@ use syn::{
104103
/// pub fn my_function() {
105104
/// // ...
106105
/// }
107-
/// # fn main() {}
108106
/// ```
109107
/// Overriding the generated span's target:
110108
/// ```
@@ -113,7 +111,6 @@ use syn::{
113111
/// pub fn my_function() {
114112
/// // ...
115113
/// }
116-
/// # fn main() {}
117114
/// ```
118115
///
119116
/// To skip recording an argument, pass the argument's name to the `skip`:
@@ -126,7 +123,6 @@ use syn::{
126123
/// fn my_function(arg: usize, non_debug: NonDebug) {
127124
/// // ...
128125
/// }
129-
/// # fn main() {}
130126
/// ```
131127
///
132128
/// If `tracing_futures` is specified as a dependency in `Cargo.toml`,
@@ -139,7 +135,6 @@ use syn::{
139135
/// // ...
140136
/// # Ok(())
141137
/// }
142-
/// # fn main() {}
143138
/// ```
144139
///
145140
/// [span]: https://docs.rs/tracing/0.1.6/tracing/span/index.html

tracing-attributes/test_async_await/tests/async_fn.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(async_await)]
2-
31
use test_std_future::{
42
PollN,
53
block_on_future,

tracing-core/src/dispatcher.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@
3838
//! # fn exit(&self, _: &Id) {}
3939
//! # }
4040
//! # impl FooSubscriber { fn new() -> Self { FooSubscriber } }
41-
//! # fn main() {
4241
//! use dispatcher::Dispatch;
4342
//!
4443
//! let my_subscriber = FooSubscriber::new();
4544
//! let my_dispatch = Dispatch::new(my_subscriber);
46-
//! # }
4745
//! ```
4846
//! Then, we can use [`with_default`] to set our `Dispatch` as the default for
4947
//! the duration of a block:
@@ -63,7 +61,6 @@
6361
//! # fn exit(&self, _: &Id) {}
6462
//! # }
6563
//! # impl FooSubscriber { fn new() -> Self { FooSubscriber } }
66-
//! # fn main() {
6764
//! # let my_subscriber = FooSubscriber::new();
6865
//! # let my_dispatch = dispatcher::Dispatch::new(my_subscriber);
6966
//! // no default subscriber
@@ -74,7 +71,6 @@
7471
//! });
7572
//!
7673
//! // no default subscriber again
77-
//! # }
7874
//! ```
7975
//! It's important to note that `with_default` will not propagate the current
8076
//! thread's default subscriber to any threads spawned within the `with_default`
@@ -100,7 +96,6 @@
10096
//! # fn exit(&self, _: &Id) {}
10197
//! # }
10298
//! # impl FooSubscriber { fn new() -> Self { FooSubscriber } }
103-
//! # fn main() {
10499
//! # let my_subscriber = FooSubscriber::new();
105100
//! # let my_dispatch = dispatcher::Dispatch::new(my_subscriber);
106101
//! // no default subscriber
@@ -111,7 +106,6 @@
111106
//! .expect("global default was already set!");
112107
//!
113108
//! // `my_subscriber` is now the default
114-
//! # }
115109
//! ```
116110
//!
117111
//! **Note**: the thread-local scoped dispatcher (`with_default`) requires the
@@ -258,7 +252,7 @@ pub fn set_global_default(dispatcher: Dispatch) -> Result<(), SetGlobalDefaultEr
258252
if GLOBAL_INIT.compare_and_swap(UNINITIALIZED, INITIALIZING, Ordering::SeqCst) == UNINITIALIZED
259253
{
260254
unsafe {
261-
GLOBAL_DISPATCH = Some(dispatcher.clone());
255+
GLOBAL_DISPATCH = Some(dispatcher);
262256
}
263257
GLOBAL_INIT.store(INITIALIZED, Ordering::SeqCst);
264258
EXISTS.store(true, Ordering::Release);

tracing-core/src/field.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ pub struct Iter {
102102
/// # extern crate tracing_core as tracing;
103103
/// use std::fmt::{self, Write};
104104
/// use tracing::field::{Value, Visit, Field};
105-
/// # fn main() {
106105
/// pub struct StringVisitor<'a> {
107106
/// string: &'a mut String,
108107
/// }
@@ -112,7 +111,6 @@ pub struct Iter {
112111
/// write!(self.string, "{} = {:?}; ", field.name(), value).unwrap();
113112
/// }
114113
/// }
115-
/// # }
116114
/// ```
117115
/// This visitor will format each recorded value using `fmt::Debug`, and
118116
/// append the field name and formatted value to the provided string,
@@ -135,7 +133,6 @@ pub struct Iter {
135133
/// # extern crate tracing_core as tracing;
136134
/// # use std::fmt::{self, Write};
137135
/// # use tracing::field::{Value, Visit, Field};
138-
/// # fn main() {
139136
/// pub struct SumVisitor {
140137
/// sum: i64,
141138
/// }
@@ -153,7 +150,6 @@ pub struct Iter {
153150
/// // Do nothing
154151
/// }
155152
/// }
156-
/// # }
157153
/// ```
158154
///
159155
/// This visitor (which is probably not particularly useful) keeps a running

tracing-subscriber/src/field/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub trait VisitOutput<Out>: Visit {
8181
/// let mut visitor = MyVisitor::new();
8282
/// r.record(&mut visitor);
8383
/// }
84-
/// # fn main() {}
8584
/// ```
8685
/// [visitor]: https://docs.rs/tracing-core/latest/tracing_core/field/trait.Visit.html
8786
/// [attr]: https://docs.rs/tracing-core/latest/tracing_core/span/struct.Attributes.html

tracing-subscriber/src/filter/env/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ impl EnvFilter {
139139
/// # Examples
140140
/// ```rust
141141
/// use tracing_subscriber::filter::{EnvFilter, LevelFilter};
142-
/// # fn main() {
143142
/// let mut filter = EnvFilter::from_default_env()
144143
/// .add_directive(LevelFilter::INFO.into());
145-
/// # }
146144
/// ```
147145
/// ```rust
148146
/// use tracing_subscriber::filter::{EnvFilter, Directive};
@@ -153,7 +151,6 @@ impl EnvFilter {
153151
/// .add_directive("my_crate::my_other_module::something=info".parse()?);
154152
/// # Ok(())
155153
/// # }
156-
/// # fn main() {}
157154
/// ```
158155
pub fn add_directive(mut self, directive: Directive) -> Self {
159156
if let Some(stat) = directive.to_static() {

tracing-subscriber/src/layer.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ where
200200
/// ```rust
201201
/// # use tracing_subscriber::layer::Layer;
202202
/// # use tracing_core::Subscriber;
203-
/// # fn main() {
204203
/// pub struct FooLayer {
205204
/// // ...
206205
/// }
@@ -243,15 +242,13 @@ where
243242
/// let subscriber = FooLayer::new()
244243
/// .and_then(BarLayer::new())
245244
/// .with_subscriber(MySubscriber::new());
246-
/// # }
247245
/// ```
248246
///
249247
/// Multiple layers may be composed in this manner:
250248
///
251249
/// ```rust
252250
/// # use tracing_subscriber::layer::Layer;
253251
/// # use tracing_core::Subscriber;
254-
/// # fn main() {
255252
/// # pub struct FooLayer {}
256253
/// # pub struct BarLayer {}
257254
/// # pub struct MySubscriber {}
@@ -289,7 +286,6 @@ where
289286
/// .and_then(BarLayer::new())
290287
/// .and_then(BazLayer::new())
291288
/// .with_subscriber(MySubscriber::new());
292-
/// # }
293289
/// ```
294290
fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
295291
where
@@ -313,7 +309,6 @@ where
313309
/// ```rust
314310
/// # use tracing_subscriber::layer::Layer;
315311
/// # use tracing_core::Subscriber;
316-
/// # fn main() {
317312
/// pub struct FooLayer {
318313
/// // ...
319314
/// }
@@ -344,7 +339,6 @@ where
344339
/// # }
345340
/// let subscriber = FooLayer::new()
346341
/// .with_subscriber(MySubscriber::new());
347-
/// # }
348342
///```
349343
///
350344
/// [`Subscriber`]: https://docs.rs/tracing-core/latest/tracing_core/trait.Subscriber.html

tracing-subscriber/src/registry/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
//! ```rust
1717
//! use tracing_subscriber::{registry::Registry, Layer};
1818
//! # use tracing_core::Subscriber;
19-
//! # fn main() {
2019
//! # pub struct FooLayer {}
2120
//! # pub struct BarLayer {}
2221
//! # impl<S: Subscriber> Layer<S> for FooLayer {}
@@ -31,7 +30,6 @@
3130
//! let subscriber = FooLayer::new()
3231
//! .and_then(BarLayer::new())
3332
//! .with_subscriber(Registry::default());
34-
//! # }
3533
//! ```
3634
//!
3735
//! If a type implementing `Layer` depends on the functionality of a `Registry`
@@ -42,7 +40,6 @@
4240
//! use tracing_subscriber::{registry, Layer};
4341
//! use tracing_core::Subscriber;
4442
//!
45-
//! # fn main() {
4643
//! pub struct MyLayer {
4744
//! // ...
4845
//! }
@@ -53,7 +50,6 @@
5350
//! {
5451
//! // ...
5552
//! }
56-
//! # }
5753
//! ```
5854
//! When this bound is added, the `Layer` implementation will be guaranteed
5955
//! access to the [`Context`][ctx] methods, such as [`Context::span`][lookup], that

0 commit comments

Comments
 (0)