Rocket/core/codegen/tests/ui-fail/uri_display.rs
Sergio Benitez b7db74144f Parameterize 'UriDisplay' with 'Path' or 'Query'.
This commit introduces the sealed `UriPart` marker trait as well as the
implementing `Path` and `Query` marker types, allowing for parts of a
URI to be distinguished at the type level. Consequently, `UriDisplay`
has been parameterized with `P: UriPart`, creating `UriDisplay<Path>`
and `UriDisplay<Query>`. The effect of this change is improved type
safely for URI rendering as well as the ability to omit rendering values
in query parts via `Option` and `Result`.

The `UriDisplay` derive was replaced by `UriDisplayQuery` and
`UriDisplayPath` which derive implementations for `UriDisplay<Path>`
and `UriDisplay<Query>`, respectively.

This commit also works around a rustdoc visibility issue by creating a
hidden `http::private` module.

Finally, this commit also removes the now vestigial use of the
`rustc_private` feature in codegen.

Fixes #827.
2018-11-27 10:01:47 -06:00

49 lines
827 B
Rust

#[macro_use] extern crate rocket;
#[derive(UriDisplayQuery)]
struct Foo1;
//~^ ERROR not supported
#[derive(UriDisplayQuery)]
struct Foo2();
//~^ ERROR not supported
#[derive(UriDisplayQuery)]
enum Foo3 { }
//~^ ERROR not supported
#[derive(UriDisplayQuery)]
enum Foo4 {
Variant,
//~^ ERROR not supported
}
#[derive(UriDisplayQuery)]
struct Foo5(String, String);
//~^ ERROR exactly one
#[derive(UriDisplayQuery)]
struct Foo6 {
#[form(field = 123)]
//~^ ERROR invalid value: expected string
field: String,
}
#[derive(UriDisplayPath)]
struct Foo7(String, usize);
//~^ ERROR exactly one
#[derive(UriDisplayPath)]
struct Foo8;
//~^ ERROR exactly one
#[derive(UriDisplayPath)]
enum Foo9 { }
//~^ ERROR not supported
#[derive(UriDisplayPath)]
struct Foo10 {
//~^ ERROR not supported
named: usize
}