diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/api/admin.rs | 6 | ||||
-rw-r--r-- | src/auth.rs | 6 | ||||
-rw-r--r-- | src/config.rs | 4 | ||||
-rw-r--r-- | src/error.rs | 6 | ||||
-rw-r--r-- | src/main.rs | 3 | ||||
-rw-r--r-- | src/util.rs | 8 |
6 files changed, 16 insertions, 17 deletions
diff --git a/src/api/admin.rs b/src/api/admin.rs index 7d81ec7b..015ec7c7 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -141,7 +141,7 @@ fn admin_url(referer: Referer) -> String { } #[get("/", rank = 2)] -fn admin_login(flash: Option<FlashMessage>) -> ApiResult<Html<String>> { +fn admin_login(flash: Option<FlashMessage<'_>>) -> ApiResult<Html<String>> { // If there is an error, show it let msg = flash.map(|msg| format!("{}: {}", msg.kind(), msg.message())); let json = json!({ @@ -164,7 +164,7 @@ struct LoginForm { #[post("/", data = "<data>")] fn post_admin_login( data: Form<LoginForm>, - cookies: &CookieJar, + cookies: &CookieJar<'_>, ip: ClientIp, referer: Referer, ) -> Result<Redirect, Flash<Redirect>> { @@ -300,7 +300,7 @@ fn test_smtp(data: Json<InviteData>, _token: AdminToken) -> EmptyResult { } #[get("/logout")] -fn logout(cookies: &CookieJar, referer: Referer) -> Redirect { +fn logout(cookies: &CookieJar<'_>, referer: Referer) -> Redirect { cookies.remove(Cookie::named(COOKIE_NAME)); Redirect::to(admin_url(referer)) } diff --git a/src/auth.rs b/src/auth.rs index 7eaf1494..a2d64b30 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -38,7 +38,7 @@ static PRIVATE_RSA_KEY: Lazy<EncodingKey> = Lazy::new(|| { static PUBLIC_RSA_KEY_VEC: Lazy<Vec<u8>> = Lazy::new(|| { read_file(&CONFIG.public_rsa_key()).unwrap_or_else(|e| panic!("Error loading public RSA Key.\n{}", e)) }); -static PUBLIC_RSA_KEY: Lazy<DecodingKey> = Lazy::new(|| { +static PUBLIC_RSA_KEY: Lazy<DecodingKey<'_>> = Lazy::new(|| { DecodingKey::from_rsa_pem(&PUBLIC_RSA_KEY_VEC).unwrap_or_else(|e| panic!("Error decoding public RSA Key.\n{}", e)) }); @@ -411,7 +411,7 @@ pub struct OrgHeaders { // org_id is usually the second path param ("/organizations/<org_id>"), // but there are cases where it is a query value. // First check the path, if this is not a valid uuid, try the query values. -fn get_org_id(request: &Request) -> Option<String> { +fn get_org_id(request: &Request<'_>) -> Option<String> { if let Some(Ok(org_id)) = request.param::<String>(1) { if uuid::Uuid::parse_str(&org_id).is_ok() { return Some(org_id); @@ -512,7 +512,7 @@ impl From<AdminHeaders> for Headers { // col_id is usually the fourth path param ("/organizations/<org_id>/collections/<col_id>"), // but there could be cases where it is a query value. // First check the path, if this is not a valid uuid, try the query values. -fn get_col_id(request: &Request) -> Option<String> { +fn get_col_id(request: &Request<'_>) -> Option<String> { if let Some(Ok(col_id)) = request.param::<String>(3) { if uuid::Uuid::parse_str(&col_id).is_ok() { return Some(col_id); diff --git a/src/config.rs b/src/config.rs index 017d7924..936353ce 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1011,7 +1011,7 @@ where fn case_helper<'reg, 'rc>( h: &Helper<'reg, 'rc>, - r: &'reg Handlebars, + r: &'reg Handlebars<'_>, ctx: &'rc Context, rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output, @@ -1028,7 +1028,7 @@ fn case_helper<'reg, 'rc>( fn js_escape_helper<'reg, 'rc>( h: &Helper<'reg, 'rc>, - _r: &'reg Handlebars, + _r: &'reg Handlebars<'_>, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output, diff --git a/src/error.rs b/src/error.rs index babe82ad..d7d49fca 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,7 +24,7 @@ macro_rules! make_error { } } impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.error {$( ErrorKind::$name(e) => f.write_str(&$usr_msg_fun(e, &self.message)), )+} @@ -93,7 +93,7 @@ make_error! { } impl std::fmt::Debug for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self.source() { Some(e) => write!(f, "{}.\n[CAUSE] {:#?}", self.message, e), None => match self.error { @@ -196,7 +196,7 @@ use rocket::request::Request; use rocket::response::{self, Responder, Response}; impl<'r> Responder<'r, 'static> for Error { - fn respond_to(self, _: &Request) -> response::Result<'static> { + fn respond_to(self, _: &Request<'_>) -> response::Result<'static> { match self.error { ErrorKind::Empty(_) => {} // Don't print the error in this situation ErrorKind::Simple(_) => {} // Don't print the error in this situation diff --git a/src/main.rs b/src/main.rs index 17305a5e..cb382723 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ #![forbid(unsafe_code)] -// #![warn(rust_2018_idioms)] +#![warn(rust_2018_idioms)] #![warn(rust_2021_compatibility)] #![cfg_attr(feature = "unstable", feature(ip))] // The recursion_limit is mainly triggered by the json!() macro. @@ -8,7 +8,6 @@ // If you go above 128 it will cause rust-analyzer to fail, #![recursion_limit = "87"] -extern crate openssl; #[macro_use] extern crate rocket; #[macro_use] diff --git a/src/util.rs b/src/util.rs index 323df413..510c0cf2 100644 --- a/src/util.rs +++ b/src/util.rs @@ -52,7 +52,7 @@ impl Fairing for AppHeaders { pub struct Cors(); impl Cors { - fn get_header(headers: &HeaderMap, name: &str) -> String { + fn get_header(headers: &HeaderMap<'_>, name: &str) -> String { match headers.get_one(name) { Some(h) => h.to_string(), _ => "".to_string(), @@ -61,7 +61,7 @@ impl Cors { // Check a request's `Origin` header against the list of allowed origins. // If a match exists, return it. Otherwise, return None. - fn get_allowed_origin(headers: &HeaderMap) -> Option<String> { + fn get_allowed_origin(headers: &HeaderMap<'_>) -> Option<String> { let origin = Cors::get_header(headers, "Origin"); let domain_origin = CONFIG.domain_origin(); let safari_extension_origin = "file://"; @@ -157,7 +157,7 @@ impl<'r, R: 'r + Responder<'r, 'static> + Send> Responder<'r, 'static> for Cache pub struct SafeString(String); impl std::fmt::Display for SafeString { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } @@ -500,7 +500,7 @@ struct UpCaseVisitor; impl<'de> Visitor<'de> for UpCaseVisitor { type Value = Value; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("an object or an array") } |