mirror of https://github.com/rwf2/Rocket.git
Fix false positives in unmounted_routes lint due to 'launch'.
This commit is contained in:
parent
0b69a5d8f7
commit
92f22ca63b
|
@ -180,10 +180,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RocketLint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((recvr, _)) = rocket_method_call("launch", cx, expr) {
|
// This captures a corner case where neither `manage` nor `mount` is
|
||||||
let instance = recvr.and_then(|r| instance_for(self, r));
|
// called on an instance.
|
||||||
self.instances.entry(instance)
|
if let Some((Some(recvr_expr), _)) = rocket_method_call("launch", cx, expr) {
|
||||||
.or_insert_with(|| InstanceInfo::default());
|
if let Some(instance) = instance_for(self, recvr_expr) {
|
||||||
|
self.instances.entry(Some(instance))
|
||||||
|
.or_insert_with(|| InstanceInfo::default());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#![feature(plugin)]
|
||||||
|
#![plugin(rocket_codegen)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
#![deny(unmounted_route)]
|
||||||
|
|
||||||
|
extern crate rocket;
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
fn index() { }
|
||||||
|
//~^ ERROR is not mounted
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
rocket::ignite().launch();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#![feature(plugin)]
|
||||||
|
#![plugin(rocket_codegen)]
|
||||||
|
#![allow(dead_code, unused_variables)]
|
||||||
|
#![deny(unmounted_routes, unmanaged_state)]
|
||||||
|
|
||||||
|
extern crate rocket;
|
||||||
|
|
||||||
|
use rocket::{Rocket, State};
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
fn index(state: State<u32>) { }
|
||||||
|
|
||||||
|
fn rocket() -> Rocket {
|
||||||
|
rocket::ignite()
|
||||||
|
.mount("/", routes![index])
|
||||||
|
.manage(100u32)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if false {
|
||||||
|
rocket().launch();
|
||||||
|
}
|
||||||
|
|
||||||
|
let instance = rocket();
|
||||||
|
if false {
|
||||||
|
instance.launch();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue