Skip to content

Commit 4238e73

Browse files
authored
Fix some clippy warnings and building with --all-features (#640)
* Fix clippy warnings * Fix doc example * Clean up tonic-web usage It looks like `tonic_web::enable` was removed with the 0.13.x release so this code hasn't actually compiled for a long time. The doc and code examples all use a custom cors layer so whatever heavy lifting the 0.12 method was doing doesn't seem necessary anymore * ci: run clippy with all features enabled Features are additive so this should be safe to lint them all together (and avoid the combinatorics of using cargo-hack) * ci: run all crate tests in one invocation 1. We've already committed our lockfile so there's no need to test the API/subscriber crates individually (if we want to test with the latest available versions we should be running a `cargo update` in CI, so this change remains compatible with the previous behavior) 2. Also enable some non-default feature flags to ensure they are being tested
1 parent 71e7f1d commit 4238e73

File tree

6 files changed

+16
-31
lines changed

6 files changed

+16
-31
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,21 @@ jobs:
7171
strategy:
7272
fail-fast: false
7373
matrix:
74-
os: [ubuntu-latest, macos-latest, windows-latest]
74+
os: [ubuntu-latest, macos-latest]
7575
rust: [stable]
76+
extraFeatures: [vsock]
7677
include:
78+
- rust: stable
79+
os: windows-latest
80+
extraFeatures: ""
7781
- rust: 1.74.0
7882
os: ubuntu-latest
83+
extraFeatures: vsock
7984
# Try to build on the latest nightly. This job is allowed to fail, but
8085
# it's useful to help catch bugs in upcoming Rust versions.
8186
- rust: nightly
8287
os: ubuntu-latest
88+
extraFeatures: vsock
8389
steps:
8490
- name: Checkout sources
8591
uses: actions/checkout@v4
@@ -95,14 +101,8 @@ jobs:
95101
with:
96102
repo-token: ${{ secrets.GITHUB_TOKEN }}
97103

98-
- name: Run cargo test (API)
99-
run: cargo test -p console-api
100-
101-
- name: Run cargo test (subscriber)
102-
run: cargo test -p console-subscriber
103-
104-
- name: Run cargo test (console)
105-
run: cargo test -p tokio-console --locked
104+
- name: Run cargo test
105+
run: cargo test --workspace --locked --features "transport,grpc-web,${{ matrix.extraFeatures }}"
106106

107107
lints:
108108
name: Lints
@@ -122,7 +122,7 @@ jobs:
122122
run: cargo fmt --all -- --check
123123

124124
- name: Run cargo clippy
125-
run: cargo clippy --workspace --all-targets --no-deps -- -D warnings
125+
run: cargo clippy --workspace --all-features --all-targets --no-deps -- -D warnings
126126

127127
docs:
128128
name: Docs

console-subscriber/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ keywords = [
2828
default = ["env-filter"]
2929
parking_lot = ["dep:parking_lot", "tracing-subscriber/parking_lot"]
3030
env-filter = ["tracing-subscriber/env-filter"]
31-
grpc-web = ["dep:tonic-web"]
31+
grpc-web = []
3232
vsock = ["dep:tokio-vsock"]
3333

3434
[dependencies]
@@ -54,9 +54,6 @@ serde = { version = "1.0.145", features = ["derive"] }
5454
serde_json = "1"
5555
crossbeam-channel = "0.5"
5656

57-
# Only for the web feature:
58-
tonic-web = { version = "0.13", optional = true }
59-
6057
# Only for the vsock feature:
6158
tokio-vsock = { version = "0.7.1", optional = true, features = ["tonic013"]}
6259

@@ -66,6 +63,7 @@ tower = { version = "0.4.12", default-features = false, features = ["util"] }
6663
futures = "0.3"
6764
http = "1.1"
6865
tower-http = { version = "0.5", features = ["cors"] }
66+
tonic-web = "0.13"
6967

7068
[lints.rust.unexpected_cfgs]
7169
level = "warn"

console-subscriber/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl Builder {
187187
/// ```
188188
/// # use console_subscriber::Builder;
189189
/// # #[cfg(feature = "vsock")]
190-
/// let builder = Builder::default().server_addr((tokio_vsock::VMADDR_CID_ANY, 6669));
190+
/// let builder = Builder::default().server_addr(tokio_vsock::VsockAddr::new(tokio_vsock::VMADDR_CID_ANY, 6669));
191191
/// ```
192192
///
193193
/// [environment variable]: `Builder::with_default_env`

console-subscriber/src/lib.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -974,16 +974,6 @@ impl Server {
974974
///
975975
/// # Examples
976976
///
977-
/// To serve the instrument server with gRPC-Web support with the default
978-
/// settings:
979-
///
980-
/// ```rust
981-
/// # async fn docs() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
982-
/// # let (_, server) = console_subscriber::ConsoleLayer::new();
983-
/// server.serve_with_grpc_web(tonic::transport::Server::default()).await
984-
/// # }
985-
/// ```
986-
///
987977
/// To serve the instrument server with gRPC-Web support and a custom CORS configuration, use the
988978
/// following code:
989979
///
@@ -1076,9 +1066,7 @@ impl Server {
10761066
instrument_server,
10771067
aggregator,
10781068
} = self.into_parts();
1079-
let router = builder
1080-
.accept_http1(true)
1081-
.add_service(tonic_web::enable(instrument_server));
1069+
let router = builder.accept_http1(true).add_service(instrument_server);
10821070
let aggregate = spawn_named(aggregator.run(), "console::aggregate");
10831071
let res = match addr {
10841072
ServerAddr::Tcp(addr) => {

console-subscriber/tests/support/subscriber.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ async fn console_client(client_stream: DuplexStream, mut test_state: TestState)
207207
// We need to return a Result from this async block, which is
208208
// why we don't unwrap the `client` here.
209209
client.map(TokioIo::new).ok_or_else(|| {
210-
std::io::Error::new(
211-
std::io::ErrorKind::Other,
210+
std::io::Error::other(
212211
"console-test error: client already taken. This shouldn't happen.",
213212
)
214213
})

tokio-console/src/conn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl Connection {
271271
}
272272
}
273273

274-
pub fn render(&self, styles: &crate::view::Styles) -> ratatui::text::Line {
274+
pub fn render(&self, styles: &crate::view::Styles) -> ratatui::text::Line<'_> {
275275
use ratatui::{
276276
style::{Color, Modifier},
277277
text::{Line, Span},

0 commit comments

Comments
 (0)