Description: break cyclic dependency
Author: Jonas Smedegaard <dr@jones.dk>
Bug-Debian: https://bugs.debian.org/1094199
Forwarded: not-needed
Last-Update: 2025-02-22
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/axum-core/Cargo.toml
+++ b/axum-core/Cargo.toml
@@ -35,8 +35,6 @@
 tracing = { version = "0.1.37", default-features = false, optional = true }
 
 [dev-dependencies]
-axum = { path = "../axum", features = ["__private"] }
-axum-extra = { path = "../axum-extra", features = ["typed-header"] }
 axum-macros = { path = "../axum-macros", features = ["__private"] }
 hyper = "1.0.0"
 tokio = { version = "1.25.0", features = ["macros"] }
--- a/axum-core/src/ext_traits/request.rs
+++ b/axum-core/src/ext_traits/request.rs
@@ -18,7 +18,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     extract::{Request, FromRequest},
     ///     body::Body,
@@ -79,7 +79,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     body::Body,
     ///     extract::{Request, FromRef, FromRequest},
@@ -133,7 +133,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     extract::{Path, Request, FromRequest},
     ///     response::{IntoResponse, Response},
@@ -185,7 +185,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     extract::{Request, FromRef, FromRequest, FromRequestParts},
     ///     http::request::Parts,
@@ -331,99 +331,3 @@
         self.with_limited_body().into_body()
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use crate::{
-        ext_traits::tests::{RequiresState, State},
-        extract::FromRef,
-    };
-    use http::Method;
-
-    #[tokio::test]
-    async fn extract_without_state() {
-        let req = Request::new(Body::empty());
-
-        let method: Method = req.extract().await.unwrap();
-
-        assert_eq!(method, Method::GET);
-    }
-
-    #[tokio::test]
-    async fn extract_body_without_state() {
-        let req = Request::new(Body::from("foobar"));
-
-        let body: String = req.extract().await.unwrap();
-
-        assert_eq!(body, "foobar");
-    }
-
-    #[tokio::test]
-    async fn extract_with_state() {
-        let req = Request::new(Body::empty());
-
-        let state = "state".to_owned();
-
-        let State(extracted_state): State<String> = req.extract_with_state(&state).await.unwrap();
-
-        assert_eq!(extracted_state, state);
-    }
-
-    #[tokio::test]
-    async fn extract_parts_without_state() {
-        let mut req = Request::builder()
-            .header("x-foo", "foo")
-            .body(Body::empty())
-            .unwrap();
-
-        let method: Method = req.extract_parts().await.unwrap();
-
-        assert_eq!(method, Method::GET);
-        assert_eq!(req.headers()["x-foo"], "foo");
-    }
-
-    #[tokio::test]
-    async fn extract_parts_with_state() {
-        let mut req = Request::builder()
-            .header("x-foo", "foo")
-            .body(Body::empty())
-            .unwrap();
-
-        let state = "state".to_owned();
-
-        let State(extracted_state): State<String> =
-            req.extract_parts_with_state(&state).await.unwrap();
-
-        assert_eq!(extracted_state, state);
-        assert_eq!(req.headers()["x-foo"], "foo");
-    }
-
-    // this stuff just needs to compile
-    #[allow(dead_code)]
-    struct WorksForCustomExtractor {
-        method: Method,
-        from_state: String,
-        body: String,
-    }
-
-    impl<S> FromRequest<S> for WorksForCustomExtractor
-    where
-        S: Send + Sync,
-        String: FromRef<S> + FromRequest<()>,
-    {
-        type Rejection = <String as FromRequest<()>>::Rejection;
-
-        async fn from_request(mut req: Request, state: &S) -> Result<Self, Self::Rejection> {
-            let RequiresState(from_state) = req.extract_parts_with_state(state).await.unwrap();
-            let method = req.extract_parts().await.unwrap();
-            let body = req.extract().await?;
-
-            Ok(Self {
-                method,
-                from_state,
-                body,
-            })
-        }
-    }
-}
--- a/axum-core/src/ext_traits/request_parts.rs
+++ b/axum-core/src/ext_traits/request_parts.rs
@@ -15,7 +15,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     extract::{Query, Path, FromRequestParts},
     ///     response::{Response, IntoResponse},
@@ -62,7 +62,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     extract::{FromRef, FromRequestParts},
     ///     response::{Response, IntoResponse},
@@ -133,60 +133,3 @@
         E::from_request_parts(self, state)
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use std::convert::Infallible;
-
-    use super::*;
-    use crate::{
-        ext_traits::tests::{RequiresState, State},
-        extract::FromRef,
-    };
-    use http::{Method, Request};
-
-    #[tokio::test]
-    async fn extract_without_state() {
-        let (mut parts, _) = Request::new(()).into_parts();
-
-        let method: Method = parts.extract().await.unwrap();
-
-        assert_eq!(method, Method::GET);
-    }
-
-    #[tokio::test]
-    async fn extract_with_state() {
-        let (mut parts, _) = Request::new(()).into_parts();
-
-        let state = "state".to_owned();
-
-        let State(extracted_state): State<String> = parts
-            .extract_with_state::<State<String>, String>(&state)
-            .await
-            .unwrap();
-
-        assert_eq!(extracted_state, state);
-    }
-
-    // this stuff just needs to compile
-    #[allow(dead_code)]
-    struct WorksForCustomExtractor {
-        method: Method,
-        from_state: String,
-    }
-
-    impl<S> FromRequestParts<S> for WorksForCustomExtractor
-    where
-        S: Send + Sync,
-        String: FromRef<S>,
-    {
-        type Rejection = Infallible;
-
-        async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
-            let RequiresState(from_state) = parts.extract_with_state(state).await?;
-            let method = parts.extract().await?;
-
-            Ok(Self { method, from_state })
-        }
-    }
-}
--- a/axum-core/src/extract/default_body_limit.rs
+++ b/axum-core/src/extract/default_body_limit.rs
@@ -24,7 +24,7 @@
 ///
 /// # Example
 ///
-/// ```
+/// ```ignore
 /// use axum::{
 ///     Router,
 ///     routing::post,
@@ -48,7 +48,7 @@
 /// `DefaultBodyLimit` can also be selectively applied to have different limits for different
 /// routes:
 ///
-/// ```
+/// ```ignore
 /// use axum::{
 ///     Router,
 ///     routing::post,
@@ -95,7 +95,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     Router,
     ///     routing::get,
@@ -129,7 +129,7 @@
     ///
     /// # Example
     ///
-    /// ```
+    /// ```ignore
     /// use axum::{
     ///     Router,
     ///     routing::get,
--- a/axum-core/src/response/append_headers.rs
+++ b/axum-core/src/response/append_headers.rs
@@ -7,7 +7,7 @@
 /// Returning something like `[("content-type", "foo=bar")]` from a handler will override any
 /// existing `content-type` headers. If instead you want to append headers, use `AppendHeaders`:
 ///
-/// ```rust
+/// ```ignore
 /// use axum::{
 ///     response::{AppendHeaders, IntoResponse},
 ///     http::header::SET_COOKIE,
--- a/axum-core/src/response/into_response.rs
+++ b/axum-core/src/response/into_response.rs
@@ -26,7 +26,7 @@
 /// However it might be necessary if you have a custom error type that you want
 /// to return from handlers:
 ///
-/// ```rust
+/// ```ignore
 /// use axum::{
 ///     Router,
 ///     body::{self, Bytes},
@@ -64,7 +64,7 @@
 /// Or if you have a custom body type you'll also need to implement
 /// `IntoResponse` for it:
 ///
-/// ```rust
+/// ```ignore
 /// use axum::{
 ///     body,
 ///     routing::get,
--- a/axum-core/src/response/into_response_parts.rs
+++ b/axum-core/src/response/into_response_parts.rs
@@ -9,7 +9,7 @@
 ///
 /// # Example
 ///
-/// ```rust
+/// ```ignore
 /// use axum::{
 ///     response::{ResponseParts, IntoResponse, IntoResponseParts, Response},
 ///     http::{StatusCode, header::{HeaderName, HeaderValue}},
--- a/axum-core/src/response/mod.rs
+++ b/axum-core/src/response/mod.rs
@@ -28,7 +28,7 @@
 ///
 /// # Example
 ///
-/// ```
+/// ```ignore
 /// use axum::{
 ///     response::{IntoResponse, Response},
 ///     http::StatusCode,
@@ -80,7 +80,7 @@
 ///
 /// Since `axum::response::Result` has a default error type you only have to specify the `Ok` type:
 ///
-/// ```
+/// ```ignore
 /// use axum::{
 ///     response::{IntoResponse, Response, Result},
 ///     http::StatusCode,
--- a/axum-macros/Cargo.toml
+++ b/axum-macros/Cargo.toml
@@ -1,4 +1,5 @@
 [package]
+exclude = ["tests/*"]
 categories = ["asynchronous", "network-programming", "web-programming"]
 description = "Macros for axum"
 edition = "2021"
@@ -29,8 +30,6 @@
 ] }
 
 [dev-dependencies]
-axum = { path = "../axum", features = ["macros"] }
-axum-extra = { path = "../axum-extra", features = ["typed-routing", "cookie-private", "typed-header"] }
 rustversion = "1.0"
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
--- a/axum-macros/src/lib.rs
+++ b/axum-macros/src/lib.rs
@@ -32,7 +32,7 @@
 ///
 /// By default `#[derive(FromRequest)]` will call `FromRequest::from_request` for each field:
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum::{
 ///     extract::Extension,
@@ -62,7 +62,7 @@
 ///
 /// Note that only the last field can consume the request body. Therefore this doesn't compile:
 ///
-/// ```compile_fail
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum::body::Bytes;
 ///
@@ -80,7 +80,7 @@
 /// You can use `#[from_request(via(...))]` to extract a field via another extractor, meaning the
 /// field itself doesn't need to implement `FromRequest`:
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum::{
 ///     extract::Extension,
@@ -126,7 +126,7 @@
 ///
 /// `#[from_request(via(...))]` supports `Option<_>` and `Result<_, _>` to make fields optional:
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum_extra::{
 ///     TypedHeader,
@@ -153,7 +153,7 @@
 /// By default [`axum::response::Response`] will be used as the rejection. You can also use your own
 /// rejection type with `#[from_request(rejection(YourType))]`:
 ///
-/// ```
+/// ```ignore
 /// use axum::{
 ///     extract::{
 ///         rejection::{ExtensionRejection, StringRejection},
@@ -201,7 +201,7 @@
 /// If the extraction can be done only for a concrete state, that type can be specified with
 /// `#[from_request(state(YourState))]`:
 ///
-/// ```
+/// ```ignore
 /// use axum::extract::{FromRequest, FromRequestParts};
 ///
 /// #[derive(Clone)]
@@ -231,7 +231,7 @@
 ///
 /// This is not needed for a `State<T>` as the type is inferred in that case.
 ///
-/// ```
+/// ```ignore
 /// use axum::extract::{FromRequest, FromRequestParts, State};
 ///
 /// #[derive(Clone)]
@@ -249,7 +249,7 @@
 /// By using `#[from_request(via(...))]` on the container you can extract the whole type at once,
 /// instead of each field individually:
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum::extract::Extension;
 ///
@@ -268,7 +268,7 @@
 ///
 /// You can use a different rejection type with `#[from_request(rejection(YourType))]`:
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum::{
 ///     extract::{Extension, rejection::ExtensionRejection},
@@ -315,7 +315,7 @@
 ///
 /// This allows you to wrap other extractors and easily customize the rejection:
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequest;
 /// use axum::{
 ///     extract::{Extension, rejection::JsonRejection},
@@ -384,7 +384,7 @@
 ///
 /// # Example
 ///
-/// ```
+/// ```ignore
 /// use axum_macros::FromRequestParts;
 /// use axum::{
 ///     extract::Query,
@@ -430,7 +430,7 @@
 ///
 /// While using [`axum`], you can get long error messages for simple mistakes. For example:
 ///
-/// ```compile_fail
+/// ```ignore
 /// use axum::{routing::get, Router};
 ///
 /// #[tokio::main]
@@ -449,7 +449,7 @@
 /// You will get a long error message about function not implementing [`Handler`] trait. But why
 /// does this function not implement it? To figure it out, the [`debug_handler`] macro can be used.
 ///
-/// ```compile_fail
+/// ```ignore
 /// # use axum::{routing::get, Router};
 /// # use axum_macros::debug_handler;
 /// #
@@ -477,7 +477,7 @@
 ///
 /// As the error message says, handler function needs to be async.
 ///
-/// ```no_run
+/// ```ignore
 /// use axum::{routing::get, Router, debug_handler};
 ///
 /// #[tokio::main]
@@ -499,7 +499,7 @@
 /// By default `#[debug_handler]` assumes your state type is `()` unless your handler has a
 /// [`axum::extract::State`] argument:
 ///
-/// ```
+/// ```ignore
 /// use axum::{debug_handler, extract::State};
 ///
 /// #[debug_handler]
@@ -515,7 +515,7 @@
 /// If your handler takes multiple [`axum::extract::State`] arguments or you need to otherwise
 /// customize the state type you can set it with `#[debug_handler(state = ...)]`:
 ///
-/// ```
+/// ```ignore
 /// use axum::{debug_handler, extract::{State, FromRef}};
 ///
 /// #[debug_handler(state = AppState)]
@@ -590,7 +590,7 @@
 ///
 /// # Example
 ///
-/// ```no_run
+/// ```ignore
 /// use axum::{
 ///     routing::get,
 ///     extract::Request,
@@ -669,7 +669,7 @@
 ///
 /// # Example
 ///
-/// ```
+/// ```ignore
 /// use axum::{
 ///     Router,
 ///     routing::get,
--- a/axum/Cargo.toml
+++ b/axum/Cargo.toml
@@ -123,7 +123,6 @@
 
 [dev-dependencies]
 anyhow = "1.0"
-axum-extra = { path = "../axum-extra", features = ["typed-header"] }
 axum-macros = { path = "../axum-macros", features = ["__private"] }
 hyper = { version = "1.1.0", features = ["client"] }
 quickcheck = "1.0"
--- a/axum-core/src/extract/request_parts.rs
+++ b/axum-core/src/extract/request_parts.rs
@@ -166,28 +166,3 @@
         Ok(req.into_body())
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use axum::{extract::Extension, routing::get, test_helpers::*, Router};
-    use http::{Method, StatusCode};
-
-    #[crate::test]
-    async fn extract_request_parts() {
-        #[derive(Clone)]
-        struct Ext;
-
-        async fn handler(parts: http::request::Parts) {
-            assert_eq!(parts.method, Method::GET);
-            assert_eq!(parts.uri, "/");
-            assert_eq!(parts.version, http::Version::HTTP_11);
-            assert_eq!(parts.headers["x-foo"], "123");
-            parts.extensions.get::<Ext>().unwrap();
-        }
-
-        let client = TestClient::new(Router::new().route("/", get(handler)).layer(Extension(Ext)));
-
-        let res = client.get("/").header("x-foo", "123").await;
-        assert_eq!(res.status(), StatusCode::OK);
-    }
-}
--- a/axum/src/docs/extract.md
+++ b/axum/src/docs/extract.md
@@ -246,7 +246,7 @@
 header you're trying to extract is not part of the request, but if the header
 is present and fails to parse, the request is rejected.
 
-```rust,no_run
+```rust,ignore
 use axum::{routing::post, Router};
 use axum_extra::{headers::UserAgent, TypedHeader};
 use serde_json::Value;
--- a/axum/src/extract/mod.rs
+++ b/axum/src/extract/mod.rs
@@ -95,20 +95,3 @@
 
     content_type.starts_with(expected_content_type.as_ref())
 }
-
-#[cfg(test)]
-mod tests {
-    use crate::{routing::get, test_helpers::*, Router};
-
-    #[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]
-    #[crate::test]
-    async fn consume_body() {
-        let app = Router::new().route("/", get(|body: String| async { body }));
-
-        let client = TestClient::new(app);
-        let res = client.get("/").body("foo").await;
-        let body = res.text().await;
-
-        assert_eq!(body, "foo");
-    }
-}
