Rocket/core/codegen/tests/ui-fail/responder.rs
Sergio Benitez 2727d7bb7b Automatically discover 'Responder' generic bounds.
This commit presents and applies a new technique for bounding type
generics in derives. In short, for a generic `T` used in a field type of
`Field<T>`, where an eventual bound of `Responder` required, the derive
generates a bound of `Field<T>: Responder`. This removes the need for
any manually provided bounds while simultaneously allowing more
structures to typecheck. For example, generics in header components are
now fully supported.
2021-06-29 03:31:31 -07:00

53 lines
916 B
Rust

#[macro_use] extern crate rocket;
#[derive(Responder)]
struct Thing1;
#[derive(Responder)]
struct Thing2();
#[derive(Responder)]
enum Bar { } // NO ERROR
#[derive(Responder)]
enum Foo { Bark, }
#[derive(Responder)]
struct Thing4<'a, 'b>(&'a str, &'b str);
#[derive(Responder)]
struct Thing5<T>(T); // NO ERROR
#[derive(Responder)]
struct Thing6<T, E>(T, E);
#[derive(Responder)]
#[response(content_type = "")]
struct Thing7(());
#[derive(Responder)]
#[response(content_type = "idk")]
struct Thing8(());
#[derive(Responder)]
#[response(content_type = 100)]
struct Thing9(());
#[derive(Responder)]
#[response(status = 8)]
struct Thing10(());
#[derive(Responder)]
#[response(status = "404")]
struct Thing11(());
#[derive(Responder)]
#[response(status = "404", content_type = "html")]
struct Thing12(());
#[derive(Responder)]
#[response(status = 404, content_type = 120)]
struct Thing13(());
fn main() {}