#![feature(plugin)] #![plugin(rocket_codegen)] #![allow(dead_code)] #![deny(unmanaged_state)] extern crate rocket; use rocket::State; struct MyType; struct MySecondType; mod external { #[get("/state/extern")] fn unmanaged(_c: ::State) { } //~^ ERROR not currently being managed #[get("/state/extern")] fn managed(_c: ::State) { } //~^ WARN is not mounted #[get("/state/extern")] fn unmanaged_unmounted(_c: ::State) { } //~^ WARN is not mounted //~^^ WARN is not mounted } #[get("/state/bad")] fn unmanaged(_b: State) { } //~^ ERROR not currently being managed //~^^ ERROR not currently being managed #[get("/state/ok")] fn managed(_a: State) { } #[get("/state/bad")] fn managed_two(_b: State) { } #[get("/state/ok")] fn unmounted_doesnt_error(_a: State) { } //~^ WARN is not mounted //~^^ WARN is not mounted #[get("/ignored")] #[allow(unmanaged_state)] fn ignored(_b: State) { } //~^ WARN is not mounted #[get("/unmounted/ignored")] #[allow(unmounted_route)] fn unmounted_ignored() { } #[get("/mounted/nonce")] fn mounted_only_once() { } //~^ WARN is not mounted fn main() { rocket::ignite() .mount("/", routes![managed, unmanaged, external::unmanaged]) .mount("/", routes![managed_two, ignored, mounted_only_once]) .manage(MyType) .manage(100u32); rocket::ignite() .mount("/", routes![managed, unmanaged, external::unmanaged]) .mount("/", routes![external::managed, managed_two]) .manage(MyType) .manage(100i32) .manage(100u32); let config = rocket::Config::development().unwrap(); // Ensure unresolved paths are handled properly by lint. rocket::Rocket::custom(config, false) .mount("/", routes![managed, unmanaged, external::unmanaged]) .mount("/", routes![managed_two, ignored, mounted_only_once]) .mount("/", routes![external::managed, external::unmanaged_unmounted]) .mount("/", routes![unmounted_doesnt_error, managed_two]) .manage(MyType) .manage(MySecondType) .manage(100i32) .manage(100u32) .manage(1u8) .manage(1i8); }