mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-20 06:54:46 +00:00
improve ui on invalid types for endpoints
This commit is contained in:
parent
90fc17e57d
commit
30edd349ed
9 changed files with 169 additions and 5 deletions
19
tests/ui/endpoint/invalid_body_ty.rs
Normal file
19
tests/ui/endpoint/invalid_body_ty.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
use gotham_restful::gotham::hyper::Method;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(endpoint)]
|
||||
struct FooResource;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FooBody {
|
||||
foo: String
|
||||
}
|
||||
|
||||
#[endpoint(method = "Method::GET", uri = "", body = true)]
|
||||
fn endpoint(_: FooBody) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
13
tests/ui/endpoint/invalid_body_ty.stderr
Normal file
13
tests/ui/endpoint/invalid_body_ty.stderr
Normal file
|
@ -0,0 +1,13 @@
|
|||
error[E0277]: the trait bound `for<'de> FooBody: serde::de::Deserialize<'de>` is not satisfied
|
||||
--> $DIR/invalid_body_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooBody) {
|
||||
| ^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `FooBody`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Body: RequestBody + Send;
|
||||
| ----------- required by this bound in `gotham_restful::Endpoint::Body`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `serde::de::DeserializeOwned` for `FooBody`
|
||||
= note: required because of the requirements on the impl of `RequestBody` for `FooBody`
|
19
tests/ui/endpoint/invalid_params_ty.rs
Normal file
19
tests/ui/endpoint/invalid_params_ty.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
use gotham_restful::gotham::hyper::Method;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(endpoint)]
|
||||
struct FooResource;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FooParams {
|
||||
foo: String
|
||||
}
|
||||
|
||||
#[endpoint(method = "Method::GET", uri = "", params = true)]
|
||||
fn endpoint(_: FooParams) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
32
tests/ui/endpoint/invalid_params_ty.stderr
Normal file
32
tests/ui/endpoint/invalid_params_ty.stderr
Normal file
|
@ -0,0 +1,32 @@
|
|||
error[E0277]: the trait bound `for<'de> FooParams: serde::de::Deserialize<'de>` is not satisfied
|
||||
--> $DIR/invalid_params_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooParams) {
|
||||
| ^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `FooParams`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Params: QueryStringExtractor<Body> + Sync;
|
||||
| -------------------------- required by this bound in `gotham_restful::Endpoint::Params`
|
||||
|
||||
error[E0277]: the trait bound `FooParams: StateData` is not satisfied
|
||||
--> $DIR/invalid_params_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooParams) {
|
||||
| ^^^^^^^^^ the trait `StateData` is not implemented for `FooParams`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Params: QueryStringExtractor<Body> + Sync;
|
||||
| -------------------------- required by this bound in `gotham_restful::Endpoint::Params`
|
||||
|
||||
error[E0277]: the trait bound `FooParams: StaticResponseExtender` is not satisfied
|
||||
--> $DIR/invalid_params_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooParams) {
|
||||
| ^^^^^^^^^ the trait `StaticResponseExtender` is not implemented for `FooParams`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Params: QueryStringExtractor<Body> + Sync;
|
||||
| -------------------------- required by this bound in `gotham_restful::Endpoint::Params`
|
19
tests/ui/endpoint/invalid_placeholders_ty.rs
Normal file
19
tests/ui/endpoint/invalid_placeholders_ty.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
use gotham_restful::gotham::hyper::Method;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(endpoint)]
|
||||
struct FooResource;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FooPlaceholders {
|
||||
foo: String
|
||||
}
|
||||
|
||||
#[endpoint(method = "Method::GET", uri = ":foo")]
|
||||
fn endpoint(_: FooPlaceholders) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
32
tests/ui/endpoint/invalid_placeholders_ty.stderr
Normal file
32
tests/ui/endpoint/invalid_placeholders_ty.stderr
Normal file
|
@ -0,0 +1,32 @@
|
|||
error[E0277]: the trait bound `for<'de> FooPlaceholders: serde::de::Deserialize<'de>` is not satisfied
|
||||
--> $DIR/invalid_placeholders_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooPlaceholders) {
|
||||
| ^^^^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `FooPlaceholders`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Placeholders: PathExtractor<Body> + Sync;
|
||||
| ------------------- required by this bound in `gotham_restful::Endpoint::Placeholders`
|
||||
|
||||
error[E0277]: the trait bound `FooPlaceholders: StateData` is not satisfied
|
||||
--> $DIR/invalid_placeholders_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooPlaceholders) {
|
||||
| ^^^^^^^^^^^^^^^ the trait `StateData` is not implemented for `FooPlaceholders`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Placeholders: PathExtractor<Body> + Sync;
|
||||
| ------------------- required by this bound in `gotham_restful::Endpoint::Placeholders`
|
||||
|
||||
error[E0277]: the trait bound `FooPlaceholders: StaticResponseExtender` is not satisfied
|
||||
--> $DIR/invalid_placeholders_ty.rs:15:16
|
||||
|
|
||||
15 | fn endpoint(_: FooPlaceholders) {
|
||||
| ^^^^^^^^^^^^^^^ the trait `StaticResponseExtender` is not implemented for `FooPlaceholders`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Placeholders: PathExtractor<Body> + Sync;
|
||||
| ------------------- required by this bound in `gotham_restful::Endpoint::Placeholders`
|
16
tests/ui/endpoint/invalid_return_type.rs
Normal file
16
tests/ui/endpoint/invalid_return_type.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
#[macro_use]
|
||||
extern crate gotham_restful;
|
||||
use gotham_restful::gotham::hyper::Method;
|
||||
|
||||
#[derive(Resource)]
|
||||
#[resource(endpoint)]
|
||||
struct FooResource;
|
||||
|
||||
struct FooResponse;
|
||||
|
||||
#[endpoint(method = "Method::GET", uri = "")]
|
||||
fn endpoint() -> FooResponse {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
10
tests/ui/endpoint/invalid_return_type.stderr
Normal file
10
tests/ui/endpoint/invalid_return_type.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
error[E0277]: the trait bound `FooResponse: ResourceResult` is not satisfied
|
||||
--> $DIR/invalid_return_type.rs:12:18
|
||||
|
|
||||
12 | fn endpoint() -> FooResponse {
|
||||
| ^^^^^^^^^^^ the trait `ResourceResult` is not implemented for `FooResponse`
|
||||
|
|
||||
::: $WORKSPACE/src/endpoint.rs
|
||||
|
|
||||
| type Output: ResourceResult + Send;
|
||||
| -------------- required by this bound in `gotham_restful::Endpoint::Output`
|
Loading…
Add table
Add a link
Reference in a new issue