Skip to content

Commit 2ce55df

Browse files
committed
Fix warnings in tests
1 parent b8fbda7 commit 2ce55df

File tree

19 files changed

+58
-19
lines changed

19 files changed

+58
-19
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ jobs:
240240
- run: make test.cargo crate=${{ matrix.crate }}
241241
careful=${{ (matrix.toolchain == 'nightly' && 'yes')
242242
|| 'no' }}
243+
env:
244+
RUSTFLAGS: -D warnings
243245

244246
test-book:
245247
name: test (Book)

benches/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#[cfg(test)]
2-
mod for_benches_only {
3-
use criterion as _;
4-
use tokio as _;
5-
}
1+
#![cfg_attr(test, expect(unused_crate_dependencies, reason = "benches"))]
62

73
use juniper::{
84
DefaultScalarValue, EmptyMutation, EmptySubscription, ExecutionError, FieldError, GraphQLEnum,

juniper_actix/examples/subscription.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This example demonstrates asynchronous subscriptions with [`actix_web`].
22
3+
#![expect(unused_crate_dependencies, reason = "example")]
4+
35
use std::{pin::Pin, time::Duration};
46

57
use actix_cors::Cors;

juniper_actix/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
33
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
4+
#![cfg_attr(test, expect(unused_crate_dependencies, reason = "examples"))]
45

56
use actix_web::{
67
Error, FromRequest, HttpMessage, HttpRequest, HttpResponse, error::JsonPayloadError,
@@ -855,6 +856,7 @@ mod subscription_tests {
855856
(HttpRequest, web::Payload, web::Data<Schema>),
856857
Output = Result<HttpResponse, Error>,
857858
> {
859+
#[expect(closure_returning_async_block, reason = "not possible")]
858860
move |req: HttpRequest, stream: web::Payload, schema: web::Data<Schema>| async move {
859861
let context = Database::new();
860862
let schema = schema.into_inner();

juniper_axum/examples/custom.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! [`Handler`]: axum::handler::Handler
44
//! [`starwars::schema`]: juniper::tests::fixtures::starwars::schema
55
6+
#![expect(unused_crate_dependencies, reason = "example")]
7+
68
use std::{net::SocketAddr, sync::Arc};
79

810
use axum::{
@@ -31,7 +33,7 @@ async fn homepage() -> Html<&'static str> {
3133
.into()
3234
}
3335

34-
pub async fn custom_subscriptions(
36+
async fn custom_subscriptions(
3537
Extension(schema): Extension<Arc<Schema>>,
3638
Extension(database): Extension<Database>,
3739
ws: WebSocketUpgrade,

juniper_axum/examples/simple.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This example demonstrates simple default integration with [`axum`].
22
3+
#![expect(unused_crate_dependencies, reason = "example")]
4+
35
use std::{net::SocketAddr, sync::Arc, time::Duration};
46

57
use axum::{
@@ -15,7 +17,7 @@ use tokio::{net::TcpListener, time::interval};
1517
use tokio_stream::wrappers::IntervalStream;
1618

1719
#[derive(Clone, Copy, Debug)]
18-
pub struct Query;
20+
struct Query;
1921

2022
#[graphql_object]
2123
impl Query {
@@ -26,7 +28,7 @@ impl Query {
2628
}
2729

2830
#[derive(Clone, Copy, Debug)]
29-
pub struct Subscription;
31+
struct Subscription;
3032

3133
type NumberStream = BoxStream<'static, Result<i32, FieldError>>;
3234

juniper_axum/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#![cfg_attr(docsrs, feature(doc_cfg))]
22
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
33
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
4+
#![cfg_attr(
5+
test,
6+
expect(unused_crate_dependencies, reason = "examples and integration tests")
7+
)]
48

59
// TODO: Try remove on upgrade of `axum` crate.
610
mod for_minimal_versions_check_only {

juniper_axum/tests/http_test_suite.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! [`HttpIntegration`] testing for [`axum`].
2+
3+
#![expect(unused_crate_dependencies, reason = "integration tests")]
4+
15
use std::sync::Arc;
26

37
use axum::{

juniper_axum/tests/ws_test_suite.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#![cfg(not(windows))]
1+
//! [`WsIntegration`] testing for [`axum`].
2+
3+
#![expect(unused_crate_dependencies, reason = "integration tests")]
4+
#![cfg_attr(windows, expect(dead_code, unused_imports, reason = "disabled"))]
25

36
use std::{net::SocketAddr, sync::Arc};
47

@@ -127,12 +130,14 @@ impl WsIntegration for TestApp {
127130
}
128131
}
129132

133+
#[cfg(not(windows))]
130134
#[tokio::test]
131135
async fn test_graphql_ws_integration() {
132136
let app = TestApp::new("graphql-ws");
133137
graphql_ws::run_test_suite(&app).await;
134138
}
135139

140+
#[cfg(not(windows))]
136141
#[tokio::test]
137142
async fn test_graphql_transport_integration() {
138143
let app = TestApp::new("graphql-transport-ws");

juniper_codegen/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
22
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
33
#![recursion_limit = "1024"]
4+
#![cfg_attr(
5+
all(test, not(doctest)),
6+
expect(unused_crate_dependencies, reason = "for doc tests only")
7+
)]
48

59
// NOTICE: Unfortunately this macro MUST be defined here, in the crate's root module, because Rust
610
// doesn't allow to export `macro_rules!` macros from a `proc-macro` crate type currently,

juniper_graphql_ws/src/graphql_transport_ws/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ mod test {
823823

824824
#[tokio::test]
825825
async fn test_init_params_ok() {
826-
let mut conn = Connection::new(new_test_schema(), |params: Variables| async move {
826+
let mut conn = Connection::new(new_test_schema(), async |params: Variables| {
827827
assert_eq!(params.get("foo"), Some(&graphql_input_value!("bar")));
828828
Ok(ConnectionConfig::new(Context(1))) as Result<_, Infallible>
829829
});
@@ -842,7 +842,7 @@ mod test {
842842

843843
#[tokio::test]
844844
async fn test_init_params_error() {
845-
let mut conn = Connection::new(new_test_schema(), |params: Variables| async move {
845+
let mut conn = Connection::new(new_test_schema(), async |params: Variables| {
846846
assert_eq!(params.get("foo"), Some(&graphql_input_value!("bar")));
847847
Err(io::Error::new(io::ErrorKind::Other, "init error"))
848848
});

juniper_graphql_ws/src/graphql_ws/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ mod test {
720720

721721
#[tokio::test]
722722
async fn test_init_params_ok() {
723-
let mut conn = Connection::new(new_test_schema(), |params: Variables| async move {
723+
let mut conn = Connection::new(new_test_schema(), async |params: Variables| {
724724
assert_eq!(params.get("foo"), Some(&graphql_input_value!("bar")));
725725
Ok(ConnectionConfig::new(Context(1))) as Result<_, Infallible>
726726
});
@@ -736,7 +736,7 @@ mod test {
736736

737737
#[tokio::test]
738738
async fn test_init_params_error() {
739-
let mut conn = Connection::new(new_test_schema(), |params: Variables| async move {
739+
let mut conn = Connection::new(new_test_schema(), async |params: Variables| {
740740
assert_eq!(params.get("foo"), Some(&graphql_input_value!("bar")));
741741
Err(io::Error::new(io::ErrorKind::Other, "init error"))
742742
});

juniper_hyper/examples/hyper_server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! This example demonstrates a simple [`hyper`] server implementation for [`juniper`].
2+
3+
#![expect(unused_crate_dependencies, reason = "example")]
4+
15
use std::{convert::Infallible, error::Error, net::SocketAddr, sync::Arc};
26

37
use hyper::{Method, Response, StatusCode, server::conn::http1, service::service_fn};

juniper_hyper/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
22
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
3+
#![cfg_attr(test, expect(unused_crate_dependencies, reason = "examples"))]
34

45
use std::{error::Error, fmt, string::FromUtf8Error, sync::Arc};
56

juniper_rocket/examples/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Example demonstrating all possible HTTP endpoints integration for [`rocket`].
22
3-
#![expect(unused_crate_dependencies, reason = "single example")]
3+
#![expect(unused_crate_dependencies, reason = "example")]
44

55
use juniper::{
66
EmptyMutation, EmptySubscription, RootNode,

juniper_subscriptions/examples/basic.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! This example demonstrates how to use a [`Coordinator`] for executing a GraphQL subscription.
2+
13
use std::pin::Pin;
24

35
use futures::{Stream, StreamExt};
@@ -8,7 +10,7 @@ use juniper::{
810
use juniper_subscriptions::Coordinator;
911

1012
#[derive(Clone)]
11-
pub struct Database;
13+
struct Database;
1214

1315
impl juniper::Context for Database {}
1416

@@ -18,7 +20,7 @@ impl Database {
1820
}
1921
}
2022

21-
pub struct Query;
23+
struct Query;
2224

2325
#[graphql_object(context = Database)]
2426
impl Query {
@@ -27,7 +29,7 @@ impl Query {
2729
}
2830
}
2931

30-
pub struct Subscription;
32+
struct Subscription;
3133

3234
type StringStream = Pin<Box<dyn Stream<Item = Result<String, FieldError>> + Send>>;
3335

juniper_warp/examples/subscription.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This example demonstrates asynchronous subscriptions with [`warp`].
22
3+
#![expect(unused_crate_dependencies, reason = "example")]
4+
35
use std::{pin::Pin, sync::Arc, time::Duration};
46

57
use futures::Stream;

juniper_warp/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
22
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
33
#![cfg_attr(docsrs, feature(doc_cfg))]
4-
#![deny(missing_docs)]
4+
#![cfg_attr(
5+
test,
6+
expect(unused_crate_dependencies, reason = "examples and integration tests")
7+
)]
58

69
// TODO: Try remove on upgrade of `warp` crate.
710
mod for_minimal_versions_check_only {
@@ -532,7 +535,7 @@ mod tests {
532535

533536
let filter = warp::path("graphql")
534537
.and(make_graphql_filter(schema, context_extractor))
535-
.recover(|rejection: warp::reject::Rejection| async move {
538+
.recover(async |rejection: warp::reject::Rejection| {
536539
rejection
537540
.find::<ExtractionError>()
538541
.map(|e| e.into_response())

juniper_warp/tests/http_test_suite.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! [`HttpIntegration`] testing for [`warp`].
2+
3+
#![expect(unused_crate_dependencies, reason = "integration tests")]
4+
15
use futures::TryStreamExt as _;
26
use itertools::Itertools as _;
37
use juniper::{

0 commit comments

Comments
 (0)