mirror of https://github.com/rwf2/Rocket.git
Allow 'non_snake_case' for generated query params.
Also adds '#[deny(non_snake_case)]' to the complete route generation test for regressions. Fixes #1003.
This commit is contained in:
parent
de076895db
commit
b7afade412
|
@ -220,9 +220,11 @@ fn query_exprs(route: &Route) -> Option<TokenStream2> {
|
||||||
|
|
||||||
let decl = match segment.kind {
|
let decl = match segment.kind {
|
||||||
Kind::Single => quote_spanned! { span =>
|
Kind::Single => quote_spanned! { span =>
|
||||||
|
#[allow(non_snake_case)]
|
||||||
let mut #ident: Option<#ty> = None;
|
let mut #ident: Option<#ty> = None;
|
||||||
},
|
},
|
||||||
Kind::Multi => quote_spanned! { span =>
|
Kind::Multi => quote_spanned! { span =>
|
||||||
|
#[allow(non_snake_case)]
|
||||||
let mut #trail = #SmallVec::<[#request::FormItem; 8]>::new();
|
let mut #trail = #SmallVec::<[#request::FormItem; 8]>::new();
|
||||||
},
|
},
|
||||||
Kind::Static => quote!()
|
Kind::Static => quote!()
|
||||||
|
@ -253,6 +255,7 @@ fn query_exprs(route: &Route) -> Option<TokenStream2> {
|
||||||
|
|
||||||
let builder = match segment.kind {
|
let builder = match segment.kind {
|
||||||
Kind::Single => quote_spanned! { span =>
|
Kind::Single => quote_spanned! { span =>
|
||||||
|
#[allow(non_snake_case)]
|
||||||
let #ident = match #ident.or_else(<#ty as #request::FromFormValue>::default) {
|
let #ident = match #ident.or_else(<#ty as #request::FromFormValue>::default) {
|
||||||
Some(__v) => __v,
|
Some(__v) => __v,
|
||||||
None => {
|
None => {
|
||||||
|
@ -262,6 +265,7 @@ fn query_exprs(route: &Route) -> Option<TokenStream2> {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
Kind::Multi => quote_spanned! { span =>
|
Kind::Multi => quote_spanned! { span =>
|
||||||
|
#[allow(non_snake_case)]
|
||||||
let #ident = match <#ty as #request::FromQuery>::from_query(#Query(&#trail)) {
|
let #ident = match <#ty as #request::FromQuery>::from_query(#Query(&#trail)) {
|
||||||
Ok(__v) => __v,
|
Ok(__v) => __v,
|
||||||
Err(__e) => {
|
Err(__e) => {
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#![feature(proc_macro_hygiene, decl_macro)]
|
#![feature(proc_macro_hygiene, decl_macro)]
|
||||||
|
|
||||||
|
// Rocket sometimes generates mangled identifiers that activate the
|
||||||
|
// non_snake_case lint. We deny the lint in this test to ensure that
|
||||||
|
// code generation uses #[allow(non_snake_case)] in the appropriate places.
|
||||||
|
#![deny(non_snake_case)]
|
||||||
|
|
||||||
#[macro_use] extern crate rocket;
|
#[macro_use] extern crate rocket;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -65,6 +70,10 @@ fn post2(
|
||||||
format!("({}) ({})", string, uri.to_string())
|
format!("({}) ({})", string, uri.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[post("/<_unused_param>?<_unused_query>", data="<_unused_data>")]
|
||||||
|
fn test_unused_params(_unused_param: String, _unused_query: String, _unused_data: Data) {
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_full_route() {
|
fn test_full_route() {
|
||||||
let rocket = rocket::ignite()
|
let rocket = rocket::ignite()
|
||||||
|
|
Loading…
Reference in New Issue