1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Update Rust to 1.69.0

This commit is contained in:
Quentin Gliech
2023-04-24 11:01:59 +02:00
parent a6d1410146
commit 3979e9f46a
7 changed files with 25 additions and 42 deletions

View File

@ -182,8 +182,8 @@ jobs:
- name: Install toolchain - name: Install toolchain
run: | run: |
rustup toolchain install 1.67.0 rustup toolchain install 1.69.0
rustup default 1.67.0 rustup default 1.69.0
rustup component add clippy rustup component add clippy
- name: Setup OPA - name: Setup OPA

View File

@ -12,7 +12,7 @@
# The Debian version and version name must be in sync # The Debian version and version name must be in sync
ARG DEBIAN_VERSION=11 ARG DEBIAN_VERSION=11
ARG DEBIAN_VERSION_NAME=bullseye ARG DEBIAN_VERSION_NAME=bullseye
ARG RUSTC_VERSION=1.67.0 ARG RUSTC_VERSION=1.69.0
# XXX: Upgrade to 0.10.0 blocked by https://github.com/ziglang/zig/issues/10915#issuecomment-1354548110 # XXX: Upgrade to 0.10.0 blocked by https://github.com/ziglang/zig/issues/10915#issuecomment-1354548110
ARG ZIG_VERSION=0.9.1 ARG ZIG_VERSION=0.9.1
ARG NODEJS_VERSION=18 ARG NODEJS_VERSION=18
@ -21,8 +21,7 @@ ARG OPA_VERSION=0.48.0
########################################## ##########################################
## Build stage that builds the frontend ## ## Build stage that builds the frontend ##
########################################## ##########################################
FROM --platform=${BUILDPLATFORM} docker.io/library/node:${NODEJS_VERSION}-${DEBIAN_VERSION_NAME} AS frontend
FROM --platform=${BUILDPLATFORM} docker.io/library/node:${NODEJS_VERSION}-${DEBIAN_VERSION_NAME}-slim AS frontend
WORKDIR /app/frontend WORKDIR /app/frontend
@ -43,11 +42,7 @@ RUN \
############################################## ##############################################
## Build stage that builds the OPA policies ## ## Build stage that builds the OPA policies ##
############################################## ##############################################
FROM --platform=${BUILDPLATFORM} docker.io/library/debian:${DEBIAN_VERSION_NAME} AS policy
FROM --platform=${BUILDPLATFORM} docker.io/library/debian:${DEBIAN_VERSION_NAME}-slim AS policy
# Install make
RUN apt update && apt install -y --no-install-recommends make
ARG BUILDOS ARG BUILDOS
ARG BUILDARCH ARG BUILDARCH
@ -64,8 +59,7 @@ RUN chmod a+r ./policy.wasm
########################################################################## ##########################################################################
## Base image with cargo-chef and the right cross-compilation toolchain ## ## Base image with cargo-chef and the right cross-compilation toolchain ##
########################################################################## ##########################################################################
FROM --platform=${BUILDPLATFORM} docker.io/library/rust:${RUSTC_VERSION}-${DEBIAN_VERSION_NAME} AS toolchain
FROM --platform=${BUILDPLATFORM} docker.io/library/rust:${RUSTC_VERSION}-slim-${DEBIAN_VERSION_NAME} AS toolchain
ARG ZIG_VERSION ARG ZIG_VERSION
ARG RUSTC_VERSION ARG RUSTC_VERSION
@ -73,11 +67,8 @@ ARG RUSTC_VERSION
# Make cargo use the git cli for fetching dependencies # Make cargo use the git cli for fetching dependencies
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
# Install the protobuf compiler, git, curl and xz # Install the protobuf compiler
RUN apt update && apt install -y --no-install-recommends \ RUN apt update && apt install -y --no-install-recommends \
git \
curl \
xz-utils \
protobuf-compiler protobuf-compiler
# Download zig compiler for cross-compilation # Download zig compiler for cross-compilation
@ -98,7 +89,6 @@ COPY ./misc/docker-arch-to-rust-target.sh /
##################################### #####################################
## Run the planner from cargo-chef ## ## Run the planner from cargo-chef ##
##################################### #####################################
FROM --platform=${BUILDPLATFORM} toolchain AS planner FROM --platform=${BUILDPLATFORM} toolchain AS planner
COPY ./Cargo.toml ./Cargo.lock /app/ COPY ./Cargo.toml ./Cargo.lock /app/
COPY ./crates /app/crates COPY ./crates /app/crates
@ -107,7 +97,6 @@ RUN cargo chef prepare --recipe-path recipe.json --bin crates/cli
######################## ########################
## Actual build stage ## ## Actual build stage ##
######################## ########################
FROM --platform=${BUILDPLATFORM} toolchain AS builder FROM --platform=${BUILDPLATFORM} toolchain AS builder
ARG TARGETPLATFORM ARG TARGETPLATFORM

View File

@ -130,7 +130,7 @@ fn stdout_tracer() -> Tracer {
} }
#[cfg(feature = "otlp")] #[cfg(feature = "otlp")]
fn otlp_tracer(endpoint: &Option<Url>) -> anyhow::Result<Tracer> { fn otlp_tracer(endpoint: Option<&Url>) -> anyhow::Result<Tracer> {
use opentelemetry_otlp::WithExportConfig; use opentelemetry_otlp::WithExportConfig;
let mut exporter = opentelemetry_otlp::new_exporter().tonic(); let mut exporter = opentelemetry_otlp::new_exporter().tonic();
@ -149,15 +149,14 @@ fn otlp_tracer(endpoint: &Option<Url>) -> anyhow::Result<Tracer> {
} }
#[cfg(not(feature = "otlp"))] #[cfg(not(feature = "otlp"))]
fn otlp_tracer(endpoint: &Option<Url>) -> anyhow::Result<Tracer> { #[allow(unused_variables)]
let _ = endpoint; fn otlp_tracer(endpoint: Option<&Url>) -> anyhow::Result<Tracer> {
anyhow::bail!("The service was compiled without OTLP exporter support, but config exports traces via OTLP.") anyhow::bail!("The service was compiled without OTLP exporter support, but config exports traces via OTLP.")
} }
#[cfg(not(feature = "jaeger"))] #[cfg(not(feature = "jaeger"))]
#[allow(unused_variables)]
fn jaeger_agent_tracer(host: &str, port: u16) -> anyhow::Result<Tracer> { fn jaeger_agent_tracer(host: &str, port: u16) -> anyhow::Result<Tracer> {
let _ = host;
let _ = port;
anyhow::bail!("The service was compiled without Jaeger exporter support, but config exports traces via Jaeger.") anyhow::bail!("The service was compiled without Jaeger exporter support, but config exports traces via Jaeger.")
} }
@ -176,15 +175,12 @@ fn jaeger_agent_tracer(host: &str, port: u16) -> anyhow::Result<Tracer> {
} }
#[cfg(not(feature = "jaeger"))] #[cfg(not(feature = "jaeger"))]
#[allow(unused_variables, clippy::unused_async)]
async fn jaeger_collector_tracer( async fn jaeger_collector_tracer(
endpoint: &str, endpoint: &str,
username: Option<&str>, username: Option<&str>,
password: Option<&str>, password: Option<&str>,
) -> anyhow::Result<Tracer> { ) -> anyhow::Result<Tracer> {
let _ = endpoint;
let _ = username;
let _ = password;
futures_util::future::ready(()).await; // Silence the "unused async" lint
anyhow::bail!("The service was compiled without Jaeger exporter support, but config exports traces via Jaeger.") anyhow::bail!("The service was compiled without Jaeger exporter support, but config exports traces via Jaeger.")
} }
@ -217,9 +213,8 @@ async fn jaeger_collector_tracer(
} }
#[cfg(not(feature = "zipkin"))] #[cfg(not(feature = "zipkin"))]
#[allow(unused_variables, clippy::unused_async)]
async fn zipkin_tracer(collector_endpoint: &Option<Url>) -> anyhow::Result<Tracer> { async fn zipkin_tracer(collector_endpoint: &Option<Url>) -> anyhow::Result<Tracer> {
let _ = collector_endpoint;
futures_util::future::ready(()).await; // Silence the "unused async" lint
anyhow::bail!("The service was compiled without Jaeger exporter support, but config exports traces via Jaeger.") anyhow::bail!("The service was compiled without Jaeger exporter support, but config exports traces via Jaeger.")
} }
@ -247,7 +242,7 @@ async fn tracer(config: &TracingExporterConfig) -> anyhow::Result<Option<Tracer>
let tracer = match config { let tracer = match config {
TracingExporterConfig::None => return Ok(None), TracingExporterConfig::None => return Ok(None),
TracingExporterConfig::Stdout => stdout_tracer(), TracingExporterConfig::Stdout => stdout_tracer(),
TracingExporterConfig::Otlp { endpoint } => otlp_tracer(endpoint)?, TracingExporterConfig::Otlp { endpoint } => otlp_tracer(endpoint.as_ref())?,
TracingExporterConfig::Jaeger(JaegerExporterProtocolConfig::UdpThriftCompact { TracingExporterConfig::Jaeger(JaegerExporterProtocolConfig::UdpThriftCompact {
agent_host, agent_host,
agent_port, agent_port,
@ -266,7 +261,7 @@ async fn tracer(config: &TracingExporterConfig) -> anyhow::Result<Option<Tracer>
} }
#[cfg(feature = "otlp")] #[cfg(feature = "otlp")]
fn otlp_meter(endpoint: &Option<url::Url>) -> anyhow::Result<BasicController> { fn otlp_meter(endpoint: Option<&url::Url>) -> anyhow::Result<BasicController> {
use opentelemetry_otlp::WithExportConfig; use opentelemetry_otlp::WithExportConfig;
let mut exporter = opentelemetry_otlp::new_exporter().tonic(); let mut exporter = opentelemetry_otlp::new_exporter().tonic();
@ -289,8 +284,8 @@ fn otlp_meter(endpoint: &Option<url::Url>) -> anyhow::Result<BasicController> {
} }
#[cfg(not(feature = "otlp"))] #[cfg(not(feature = "otlp"))]
fn otlp_meter(endpoint: &Option<url::Url>) -> anyhow::Result<BasicController> { #[allow(unused_variables)]
let _ = endpoint; fn otlp_meter(endpoint: Option<&url::Url>) -> anyhow::Result<BasicController> {
anyhow::bail!("The service was compiled without OTLP exporter support, but config exports metrics via OTLP.") anyhow::bail!("The service was compiled without OTLP exporter support, but config exports metrics via OTLP.")
} }
@ -396,7 +391,7 @@ fn meter(config: &MetricsExporterConfig) -> anyhow::Result<Option<BasicControlle
let controller = match config { let controller = match config {
MetricsExporterConfig::None => None, MetricsExporterConfig::None => None,
MetricsExporterConfig::Stdout => Some(stdout_meter()?), MetricsExporterConfig::Stdout => Some(stdout_meter()?),
MetricsExporterConfig::Otlp { endpoint } => Some(otlp_meter(endpoint)?), MetricsExporterConfig::Otlp { endpoint } => Some(otlp_meter(endpoint.as_ref())?),
MetricsExporterConfig::Prometheus => Some(prometheus_meter()?), MetricsExporterConfig::Prometheus => Some(prometheus_meter()?),
}; };

View File

@ -188,7 +188,7 @@ pub async fn post(
existing_params, existing_params,
login_token: &login.login_token, login_token: &login.login_token,
}; };
let query = serde_urlencoded::to_string(&params)?; let query = serde_urlencoded::to_string(params)?;
redirect_uri.set_query(Some(&query)); redirect_uri.set_query(Some(&query));
redirect_uri redirect_uri
}; };

View File

@ -42,8 +42,11 @@ use crate::{
MatrixHomeserver, MatrixHomeserver,
}; };
// This might fail if it's not the first time it's being called, which is fine,
// so we ignore the result
#[allow(unused_must_use)]
pub(crate) fn init_tracing() { pub(crate) fn init_tracing() {
let _ = tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO) .with_max_level(tracing::Level::INFO)
.with_test_writer() .with_test_writer()
.try_init(); .try_init();

View File

@ -46,8 +46,6 @@ mod tests {
#[sqlx::test(migrator = "crate::MIGRATOR")] #[sqlx::test(migrator = "crate::MIGRATOR")]
async fn test_session_repository(pool: PgPool) { async fn test_session_repository(pool: PgPool) {
const FIRST_TOKEN: &str = "first_access_token";
const SECOND_TOKEN: &str = "second_access_token";
let mut rng = ChaChaRng::seed_from_u64(42); let mut rng = ChaChaRng::seed_from_u64(42);
let clock = MockClock::default(); let clock = MockClock::default();
let mut repo = PgRepository::from_pool(&pool).await.unwrap(); let mut repo = PgRepository::from_pool(&pool).await.unwrap();

View File

@ -82,11 +82,9 @@ impl State {
&self.mailer &self.mailer
} }
// This is fine for now, we may move that to a trait at some point.
#[allow(clippy::unused_self, clippy::disallowed_methods)]
pub fn rng(&self) -> rand_chacha::ChaChaRng { pub fn rng(&self) -> rand_chacha::ChaChaRng {
let _ = self;
// This is fine.
#[allow(clippy::disallowed_methods)]
rand_chacha::ChaChaRng::from_rng(rand::thread_rng()).expect("failed to seed rng") rand_chacha::ChaChaRng::from_rng(rand::thread_rng()).expect("failed to seed rng")
} }