mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Move axum-debug into axum-macros (#724)
* Move axum-debug into axum-macros * fix ref to axum-macros in changelog * Apply suggestions from code review Co-authored-by: Jonas Platte <[email protected]> Co-authored-by: Jonas Platte <[email protected]>
This commit is contained in:
co-authored by
Jonas Platte
parent
b1283e9708
commit
f6fc5ed80c
@@ -0,0 +1,10 @@
|
||||
use axum_macros::FromRequest;
|
||||
use axum::extract::Extension;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor(#[from_request(via(Extension), via(Extension))] State);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct State;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,13 @@
|
||||
error: `via` specified more than once
|
||||
--> tests/from_request/fail/double_via_attr.rs:5:49
|
||||
|
|
||||
5 | struct Extractor(#[from_request(via(Extension), via(Extension))] State);
|
||||
| ^^^
|
||||
|
||||
warning: unused import: `axum::extract::Extension`
|
||||
--> tests/from_request/fail/double_via_attr.rs:2:5
|
||||
|
|
||||
2 | use axum::extract::Extension;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
@@ -0,0 +1,6 @@
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor<T>(Option<T>);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: `#[derive(FromRequest)] doesn't support generics
|
||||
--> tests/from_request/fail/generic.rs:4:17
|
||||
|
|
||||
4 | struct Extractor<T>(Option<T>);
|
||||
| ^^^
|
||||
@@ -0,0 +1,6 @@
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor(#[from_request(foo)] String);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected `via`
|
||||
--> tests/from_request/fail/unknown_attr.rs:4:33
|
||||
|
|
||||
4 | struct Extractor(#[from_request(foo)] String);
|
||||
| ^^^
|
||||
@@ -0,0 +1,11 @@
|
||||
use axum_macros::FromRequest;
|
||||
use axum::extract::Extension;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
#[from_request(via(Extension))]
|
||||
struct Extractor(#[from_request(via(Extension))] State);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct State;
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,13 @@
|
||||
error: `#[from_request(via(...))]` on a field cannot be used together with `#[from_request(...)]` on the container
|
||||
--> tests/from_request/fail/via_on_container_and_field.rs:6:33
|
||||
|
|
||||
6 | struct Extractor(#[from_request(via(Extension))] State);
|
||||
| ^^^
|
||||
|
||||
warning: unused import: `axum::extract::Extension`
|
||||
--> tests/from_request/fail/via_on_container_and_field.rs:2:5
|
||||
|
|
||||
2 | use axum::extract::Extension;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
Reference in New Issue
Block a user