diff --git a/codegen/src/decorators/route.rs b/codegen/src/decorators/route.rs index f94e63d7..6d59ec25 100644 --- a/codegen/src/decorators/route.rs +++ b/codegen/src/decorators/route.rs @@ -41,10 +41,10 @@ fn media_type_to_expr(ecx: &ExtCtxt, ct: Option) -> Option> { impl RouteParams { fn missing_declared_err(&self, ecx: &ExtCtxt, arg: &Spanned) { - let fn_span = self.annotated_fn.span(); - let msg = format!("'{}' is declared as an argument...", arg.node); - ecx.span_err(arg.span, &msg); - ecx.span_err(fn_span, "...but isn't in the function signature."); + let (fn_span, fn_name) = (self.annotated_fn.span(), self.annotated_fn.ident()); + ecx.struct_span_err(arg.span, &format!("unused dynamic parameter: `{}`", arg.node)) + .span_note(fn_span, &format!("expected argument named `{}` in `{}`", arg.node, fn_name)) + .emit(); } fn gen_form(&self, diff --git a/codegen/tests/compile-fail/ignored_params.rs b/codegen/tests/compile-fail/ignored_params.rs index 0d926e30..5cb68a44 100644 --- a/codegen/tests/compile-fail/ignored_params.rs +++ b/codegen/tests/compile-fail/ignored_params.rs @@ -1,16 +1,16 @@ #![feature(plugin)] #![plugin(rocket_codegen)] -#[get("/")] //~ ERROR 'name' is declared -fn get(other: usize) -> &'static str { "hi" } //~ ERROR isn't in the function +#[get("/")] //~ ERROR unused dynamic parameter: `name` +fn get(other: usize) -> &'static str { "hi" } //~ NOTE expected -#[get("/a?")] //~ ERROR 'r' is declared -fn get1() -> &'static str { "hi" } //~ ERROR isn't in the function +#[get("/a?")] //~ ERROR unused dynamic parameter: `r` +fn get1() -> &'static str { "hi" } //~ NOTE expected -#[post("/a", data = "")] //~ ERROR 'test' is declared -fn post() -> &'static str { "hi" } //~ ERROR isn't in the function +#[post("/a", data = "")] //~ ERROR unused dynamic parameter: `test` +fn post() -> &'static str { "hi" } //~ NOTE expected -#[get("/<_r>")] //~ ERROR '_r' is declared -fn get2(r: usize) -> &'static str { "hi" } //~ ERROR isn't in the function +#[get("/<_r>")] //~ ERROR unused dynamic parameter: `_r` +fn get2(r: usize) -> &'static str { "hi" } //~ NOTE expected fn main() { } diff --git a/codegen/tests/compile-fail/phantom-declared-param.rs b/codegen/tests/compile-fail/phantom-declared-param.rs index 16d38a77..8914593c 100644 --- a/codegen/tests/compile-fail/phantom-declared-param.rs +++ b/codegen/tests/compile-fail/phantom-declared-param.rs @@ -1,17 +1,17 @@ #![feature(plugin)] #![plugin(rocket_codegen)] -#[get("/")] //~ ERROR declared -fn get() { } //~ ERROR isn't in the function signature +#[get("/")] //~ ERROR unused dynamic parameter: `param` +fn get() { } //~ NOTE expected -#[get("/")] //~ ERROR declared -fn get2() { } //~ ERROR isn't in the function signature +#[get("/")] //~ ERROR unused dynamic parameter: `a` +fn get2() { } //~ NOTE expected #[get("/a/b/c//")] - //~^ ERROR 'a' is declared - //~^^ ERROR 'b' is declared + //~^ ERROR unused dynamic parameter: `a` + //~^^ ERROR unused dynamic parameter: `b` fn get32() { } - //~^ ERROR isn't in the function signature - //~^^ ERROR isn't in the function signature + //~^ NOTE expected + //~^^ NOTE expected fn main() { }