mirror of https://github.com/rwf2/Rocket.git
Use the correct span for 'rocket_param_' idents.
This commit is contained in:
parent
26e64e826e
commit
eb1ce54800
|
@ -142,16 +142,18 @@ impl RouteGenerateExt for RouteParams {
|
|||
let mut declared_set = HashSet::new();
|
||||
for (i, param) in self.path_params(ecx).enumerate() {
|
||||
declared_set.insert(param.ident().name);
|
||||
let ty = match self.annotated_fn.find_input(¶m.ident().name) {
|
||||
Some(arg) => strip_ty_lifetimes(arg.ty.clone()),
|
||||
let arg = match self.annotated_fn.find_input(¶m.ident().name) {
|
||||
Some(arg) => arg,
|
||||
None => {
|
||||
self.missing_declared_err(ecx, param.inner());
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let ty = strip_ty_lifetimes(arg.ty.clone());
|
||||
let ident = arg.ident().expect("function argument ident").prepend(PARAM_PREFIX);
|
||||
|
||||
// Note: the `None` case shouldn't happen if a route is matched.
|
||||
let ident = param.ident().prepend(PARAM_PREFIX);
|
||||
let expr = match param {
|
||||
Param::Single(_) => quote_expr!(ecx, match __req.get_param_str($i) {
|
||||
Some(s) => <$ty as ::rocket::request::FromParam>::from_param(s),
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(rocket_codegen)]
|
||||
|
||||
extern crate rocket;
|
||||
|
||||
#[get("/easy/<id>")]
|
||||
fn easy(id: i32) -> String {
|
||||
format!("id: {}", id)
|
||||
}
|
||||
|
||||
macro_rules! make_handler {
|
||||
() => {
|
||||
#[get("/hard/<id>")]
|
||||
fn hard(id: i32) -> String {
|
||||
format!("id: {}", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
make_handler!();
|
||||
|
||||
fn main() { }
|
Loading…
Reference in New Issue