diff --git a/contrib/lib/src/compression/mod.rs b/contrib/lib/src/compression/mod.rs index 8ba9f3d5..fc3d4a7c 100644 --- a/contrib/lib/src/compression/mod.rs +++ b/contrib/lib/src/compression/mod.rs @@ -81,7 +81,11 @@ impl CompressionUtils { } } - fn compress_response(request: &Request<'_>, response: &mut Response<'_>, exclusions: &[MediaType]) { + fn compress_response( + request: &Request<'_>, + response: &mut Response<'_>, + exclusions: &[MediaType] + ) { if CompressionUtils::already_encoded(response) { return; } @@ -124,7 +128,8 @@ impl CompressionUtils { #[cfg(feature = "gzip_compression")] { if let Some(plain) = response.take_body() { - let compressor = GzEncoder::new(plain.into_inner(), flate2::Compression::default()); + let compressor = + GzEncoder::new(plain.into_inner(), flate2::Compression::default()); CompressionUtils::set_body_and_encoding(response, compressor, Encoding::Gzip); } diff --git a/core/codegen/src/bang/uri_parsing.rs b/core/codegen/src/bang/uri_parsing.rs index 020a6f92..9b941275 100644 --- a/core/codegen/src/bang/uri_parsing.rs +++ b/core/codegen/src/bang/uri_parsing.rs @@ -239,7 +239,14 @@ impl Parse for InternalUriParams { None => vec![] }; - Ok(InternalUriParams { route_uri, mount_params, path_params, query_params, fn_args, uri_params }) + Ok(InternalUriParams { + route_uri, + mount_params, + path_params, + query_params, + fn_args, + uri_params + }) } } diff --git a/core/codegen/src/derive/responder.rs b/core/codegen/src/derive/responder.rs index 6454f5aa..06d74150 100644 --- a/core/codegen/src/derive/responder.rs +++ b/core/codegen/src/derive/responder.rs @@ -17,7 +17,8 @@ struct FieldAttr { } pub fn derive_responder(input: proc_macro::TokenStream) -> TokenStream { - DeriveGenerator::build_for(input, quote!(impl<'__r, '__o: '__r> ::rocket::response::Responder<'__r, '__o>)) + let impl_tokens = quote!(impl<'__r, '__o: '__r> ::rocket::response::Responder<'__r, '__o>); + DeriveGenerator::build_for(input, impl_tokens) .support(Support::Struct | Support::Enum | Support::Lifetime | Support::Type) .replace_generic(1, 0) .type_bound(quote!(::rocket::response::Responder<'__r, '__o>)) diff --git a/core/lib/src/config/config.rs b/core/lib/src/config/config.rs index 2a81597c..2a59af45 100644 --- a/core/lib/src/config/config.rs +++ b/core/lib/src/config/config.rs @@ -339,7 +339,7 @@ impl Config { warn!("found set deprecated profile `{}`", Paint::white(profile)); if let Some(new_profile) = replacement { - launch_info_!("profile has been by replaced by `{}`", Paint::white(new_profile)); + launch_info_!("profile was replaced by `{}`", Paint::white(new_profile)); } else { launch_info_!("profile `{}` has no special meaning", profile); } diff --git a/examples/cookies/src/session.rs b/examples/cookies/src/session.rs index ff83d385..0b2bba8e 100644 --- a/examples/cookies/src/session.rs +++ b/examples/cookies/src/session.rs @@ -60,9 +60,9 @@ fn login_page(flash: Option>) -> Template { } #[post("/login", data = "")] -fn post_login(cookies: &CookieJar<'_>, login: Form>) -> Result> { +fn post_login(jar: &CookieJar<'_>, login: Form>) -> Result> { if login.username == "Sergio" && login.password == "password" { - cookies.add_private(Cookie::new("user_id", 1.to_string())); + jar.add_private(Cookie::new("user_id", 1.to_string())); Ok(Redirect::to(uri!(index))) } else { Err(Flash::error(Redirect::to(uri!(login_page)), "Invalid username/password.")) @@ -70,8 +70,8 @@ fn post_login(cookies: &CookieJar<'_>, login: Form>) -> Result) -> Flash { - cookies.remove_private(Cookie::named("user_id")); +fn logout(jar: &CookieJar<'_>) -> Flash { + jar.remove_private(Cookie::named("user_id")); Flash::success(Redirect::to(uri!(login_page)), "Successfully logged out.") } diff --git a/scripts/test.sh b/scripts/test.sh index f9f2f27c..37afe3e9 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -30,20 +30,27 @@ function check_versions_match() { done } -# Ensures there are no tabs in any file. -function ensure_tab_free() { +function check_style() { + # Ensure there are no tabs in any file. local tab=$(printf '\t') - local matches=$(git grep -E -I "${tab}" "${PROJECT_ROOT}" | grep -v 'LICENSE') + local matches=$(git grep -E -I -n "${tab}" "${PROJECT_ROOT}" | grep -v 'LICENSE') if ! [ -z "${matches}" ]; then echo "Tab characters were found in the following:" echo "${matches}" exit 1 fi -} -# Ensures there are no files with trailing whitespace. -function ensure_trailing_whitespace_free() { - local matches=$(git grep -E -I "\s+$" "${PROJECT_ROOT}" | grep -v -F '.stderr:') + # Ensure non-comment lines are under 100 characters. + local n=100 + local matches=$(git grep -P -I -n "(?=^..{$n,}$)(?!^\s*\/\/[\/!].*$).*" '*.rs') + if ! [ -z "${matches}" ]; then + echo "Lines longer than $n characters were found in the following:" + echo "${matches}" + exit 1 + fi + + # Ensure there's no trailing whitespace. + local matches=$(git grep -E -I -n "\s+$" "${PROJECT_ROOT}" | grep -v -F '.stderr:') if ! [ -z "${matches}" ]; then echo "Trailing whitespace was found in the following:" echo "${matches}" @@ -148,11 +155,8 @@ echo " EXTRA FLAGS: $@" echo ":: Ensuring all crate versions match..." check_versions_match "${ALL_PROJECT_DIRS[@]}" -echo ":: Checking for tabs..." -ensure_tab_free - -echo ":: Checking for trailing whitespace..." -ensure_trailing_whitespace_free +echo ":: Ensuring minimum style requirements are met..." +check_style echo ":: Updating dependencies..." if ! $CARGO update ; then