From f38926d666bc9cabaa95c7bba46eb3894aa80dce Mon Sep 17 00:00:00 2001 From: BlackDex Date: Fri, 19 Nov 2021 17:50:16 +0100 Subject: [PATCH] Upd Dockerfiles, crates. Fixed rust 2018 idioms - Updated crates - Fixed Dockerfiles to build using the rust stable version - Enabled warnings for rust 2018 idioms and fixed them. --- docker/Dockerfile.j2 | 5 ++++- docker/amd64/Dockerfile | 5 ++++- docker/amd64/Dockerfile.alpine | 5 ++++- docker/amd64/Dockerfile.buildx | 5 ++++- docker/amd64/Dockerfile.buildx.alpine | 5 ++++- docker/arm64/Dockerfile | 5 ++++- docker/arm64/Dockerfile.alpine | 5 ++++- docker/arm64/Dockerfile.buildx | 5 ++++- docker/arm64/Dockerfile.buildx.alpine | 5 ++++- docker/armv6/Dockerfile | 5 ++++- docker/armv6/Dockerfile.alpine | 5 ++++- docker/armv6/Dockerfile.buildx | 5 ++++- docker/armv6/Dockerfile.buildx.alpine | 5 ++++- docker/armv7/Dockerfile | 5 ++++- docker/armv7/Dockerfile.alpine | 5 ++++- docker/armv7/Dockerfile.buildx | 5 ++++- docker/armv7/Dockerfile.buildx.alpine | 5 ++++- src/api/admin.rs | 6 +++--- src/auth.rs | 6 +++--- src/config.rs | 4 ++-- src/error.rs | 6 +++--- src/main.rs | 3 +-- src/util.rs | 8 ++++---- 23 files changed, 84 insertions(+), 34 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index c615f0db..2cffc647 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -241,7 +241,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault {% if package_arch_target is defined %} COPY --from=build /app/target/{{ package_arch_target }}/release/vaultwarden . @@ -255,5 +254,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile index dcc62eda..3af0f411 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/Dockerfile @@ -115,7 +115,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/release/vaultwarden . @@ -125,5 +124,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.alpine b/docker/amd64/Dockerfile.alpine index ea079917..189f50e6 100644 --- a/docker/amd64/Dockerfile.alpine +++ b/docker/amd64/Dockerfile.alpine @@ -107,7 +107,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/vaultwarden . @@ -117,5 +116,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.buildx b/docker/amd64/Dockerfile.buildx index 09c43d8e..05b6b71d 100644 --- a/docker/amd64/Dockerfile.buildx +++ b/docker/amd64/Dockerfile.buildx @@ -115,7 +115,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/release/vaultwarden . @@ -125,5 +124,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.buildx.alpine b/docker/amd64/Dockerfile.buildx.alpine index 6ec91417..066b8fe1 100644 --- a/docker/amd64/Dockerfile.buildx.alpine +++ b/docker/amd64/Dockerfile.buildx.alpine @@ -107,7 +107,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/vaultwarden . @@ -117,5 +116,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index 0e166e6e..d3a32dc4 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -139,7 +139,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/vaultwarden . @@ -149,5 +148,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile.alpine b/docker/arm64/Dockerfile.alpine index de37ac18..6890d7bf 100644 --- a/docker/arm64/Dockerfile.alpine +++ b/docker/arm64/Dockerfile.alpine @@ -111,7 +111,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-musl/release/vaultwarden . @@ -121,5 +120,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile.buildx b/docker/arm64/Dockerfile.buildx index b6e4f570..b93cd90e 100644 --- a/docker/arm64/Dockerfile.buildx +++ b/docker/arm64/Dockerfile.buildx @@ -139,7 +139,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/vaultwarden . @@ -149,5 +148,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile.buildx.alpine b/docker/arm64/Dockerfile.buildx.alpine index 18ce076f..dd4107c6 100644 --- a/docker/arm64/Dockerfile.buildx.alpine +++ b/docker/arm64/Dockerfile.buildx.alpine @@ -111,7 +111,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-musl/release/vaultwarden . @@ -121,5 +120,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile b/docker/armv6/Dockerfile index 050bcc65..e9e6d4bb 100644 --- a/docker/armv6/Dockerfile +++ b/docker/armv6/Dockerfile @@ -139,7 +139,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/vaultwarden . @@ -149,5 +148,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile.alpine b/docker/armv6/Dockerfile.alpine index ef5f0244..19f7f936 100644 --- a/docker/armv6/Dockerfile.alpine +++ b/docker/armv6/Dockerfile.alpine @@ -111,7 +111,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-musleabi/release/vaultwarden . @@ -121,5 +120,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile.buildx b/docker/armv6/Dockerfile.buildx index d79409cc..7d6131bf 100644 --- a/docker/armv6/Dockerfile.buildx +++ b/docker/armv6/Dockerfile.buildx @@ -139,7 +139,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/vaultwarden . @@ -149,5 +148,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile.buildx.alpine b/docker/armv6/Dockerfile.buildx.alpine index 0abcf50c..5e9d68f9 100644 --- a/docker/armv6/Dockerfile.buildx.alpine +++ b/docker/armv6/Dockerfile.buildx.alpine @@ -111,7 +111,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-musleabi/release/vaultwarden . @@ -121,5 +120,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile b/docker/armv7/Dockerfile index 18c73176..3ac3f106 100644 --- a/docker/armv7/Dockerfile +++ b/docker/armv7/Dockerfile @@ -139,7 +139,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden . @@ -149,5 +148,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.alpine b/docker/armv7/Dockerfile.alpine index 26624ee1..1ed36519 100644 --- a/docker/armv7/Dockerfile.alpine +++ b/docker/armv7/Dockerfile.alpine @@ -114,7 +114,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-musleabihf/release/vaultwarden . @@ -124,5 +123,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.buildx b/docker/armv7/Dockerfile.buildx index 18420adb..8df0f309 100644 --- a/docker/armv7/Dockerfile.buildx +++ b/docker/armv7/Dockerfile.buildx @@ -139,7 +139,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden . @@ -149,5 +148,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.buildx.alpine b/docker/armv7/Dockerfile.buildx.alpine index 2dae7cf0..56d8e7ff 100644 --- a/docker/armv7/Dockerfile.buildx.alpine +++ b/docker/armv7/Dockerfile.buildx.alpine @@ -114,7 +114,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-musleabihf/release/vaultwarden . @@ -124,5 +123,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] 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) -> ApiResult> { +fn admin_login(flash: Option>) -> ApiResult> { // 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 = "")] fn post_admin_login( data: Form, - cookies: &CookieJar, + cookies: &CookieJar<'_>, ip: ClientIp, referer: Referer, ) -> Result> { @@ -300,7 +300,7 @@ fn test_smtp(data: Json, _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 = Lazy::new(|| { static PUBLIC_RSA_KEY_VEC: Lazy> = 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 = Lazy::new(|| { +static PUBLIC_RSA_KEY: Lazy> = 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/"), // 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 { +fn get_org_id(request: &Request<'_>) -> Option { if let Some(Ok(org_id)) = request.param::(1) { if uuid::Uuid::parse_str(&org_id).is_ok() { return Some(org_id); @@ -512,7 +512,7 @@ impl From for Headers { // col_id is usually the fourth path param ("/organizations//collections/"), // 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 { +fn get_col_id(request: &Request<'_>) -> Option { if let Some(Ok(col_id)) = request.param::(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 efe38754..d2a52ef9 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 { + fn get_allowed_origin(headers: &HeaderMap<'_>) -> Option { 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") }