Skip to content

Update Rust to v1.87.0 #11182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# renovate: datasource=github-tags depName=rust lookupName=rust-lang/rust
ARG RUST_VERSION=1.86.0
ARG RUST_VERSION=1.87.0

FROM rust:$RUST_VERSION

Expand Down
7 changes: 3 additions & 4 deletions crates/crates_io_tarball/src/limit_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ impl<R: AsyncRead + Unpin> AsyncRead for LimitErrorReader<R> {
) -> Poll<io::Result<()>> {
let reader = Pin::new(&mut self.inner);
match reader.poll_read(cx, buf) {
Poll::Ready(Ok(())) if self.inner.limit() == 0 => Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"maximum limit reached when reading",
))),
Poll::Ready(Ok(())) if self.inner.limit() == 0 => {
Poll::Ready(Err(io::Error::other("maximum limit reached when reading")))
}
e => e,
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.86.0"
channel = "1.87.0"
4 changes: 1 addition & 3 deletions src/bin/crates-admin/render_readmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ async fn get_readme(
));
}

let reader = response
.bytes_stream()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e));
let reader = response.bytes_stream().map_err(std::io::Error::other);
let reader = StreamReader::new(reader);
let reader = GzipDecoder::new(reader);
let archive = Archive::new(reader);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/krate/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const MAX_DESCRIPTION_LENGTH: usize = 1000;
)]
pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<GoodCrate>> {
let stream = body.into_data_stream();
let stream = stream.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err));
let stream = stream.map_err(std::io::Error::other);
let mut reader = StreamReader::new(stream);

// The format of the req.body() of a publish request is as follows:
Expand Down
24 changes: 13 additions & 11 deletions src/middleware/block_traffic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::app::AppState;
use crate::middleware::log_request::RequestLogExt;
use crate::middleware::real_ip::RealIp;
use crate::util::errors::custom;
use crate::util::errors::{BoxedAppError, custom};
use axum::extract::{Extension, MatchedPath, Request};
use axum::middleware::Next;
use axum::response::{IntoResponse, Response};
Expand All @@ -14,9 +14,9 @@ pub async fn middleware(
req: Request,
next: Next,
) -> Result<impl IntoResponse, Response> {
block_by_ip(&real_ip, &state, req.headers())?;
block_by_header(&state, &req)?;
block_routes(matched_path.as_ref(), &state)?;
block_by_ip(&real_ip, &state, req.headers()).map_err(IntoResponse::into_response)?;
block_by_header(&state, &req).map_err(IntoResponse::into_response)?;
block_routes(matched_path.as_ref(), &state).map_err(IntoResponse::into_response)?;

Ok(next.run(req).await)
}
Expand All @@ -29,7 +29,7 @@ pub async fn middleware(
/// to `User-Agent=BLOCKED_UAS` and `BLOCKED_UAS` to `curl/7.54.0,cargo 1.36.0 (c4fcfb725 2019-05-15)`
/// to block requests from the versions of curl or Cargo specified (values are nonsensical examples).
/// Values of the headers must match exactly.
pub fn block_by_header(state: &AppState, req: &Request) -> Result<(), Response> {
pub fn block_by_header(state: &AppState, req: &Request) -> Result<(), impl IntoResponse> {
let blocked_traffic = &state.config.blocked_traffic;

for (header_name, blocked_values) in blocked_traffic {
Expand All @@ -53,15 +53,15 @@ pub fn block_by_ip(
real_ip: &RealIp,
state: &AppState,
headers: &HeaderMap,
) -> Result<(), Response> {
) -> Result<(), impl IntoResponse> {
if state.config.blocked_ips.contains(real_ip) {
return Err(rejection_response_from(state, headers));
}

Ok(())
}

fn rejection_response_from(state: &AppState, headers: &HeaderMap) -> Response {
fn rejection_response_from(state: &AppState, headers: &HeaderMap) -> impl IntoResponse {
let domain_name = &state.config.domain_name;

// Heroku should always set this header
Expand All @@ -77,17 +77,19 @@ fn rejection_response_from(state: &AppState, headers: &HeaderMap) -> Response {
Please email [email protected] and provide the request id {request_id}"
);

(StatusCode::FORBIDDEN, body).into_response()
(StatusCode::FORBIDDEN, body)
}

/// Allow blocking individual routes by their pattern through the `BLOCKED_ROUTES`
/// environment variable.
pub fn block_routes(matched_path: Option<&MatchedPath>, state: &AppState) -> Result<(), Response> {
pub fn block_routes(
matched_path: Option<&MatchedPath>,
state: &AppState,
) -> Result<(), BoxedAppError> {
if let Some(matched_path) = matched_path {
if state.config.blocked_routes.contains(matched_path.as_str()) {
let body = "This route is temporarily blocked. See https://status.crates.io.";
let error = custom(StatusCode::SERVICE_UNAVAILABLE, body);
return Err(error.into_response());
return Err(custom(StatusCode::SERVICE_UNAVAILABLE, body));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mod tests {
query_string: None,
env: Default::default(),
};
let err = std::io::Error::new(std::io::ErrorKind::Other, "error");
let err = std::io::Error::other("error");

let opts = options(SentryConfig::default());
let event_req = req.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ mod tests {
StatusCode::INTERNAL_SERVER_ERROR
);
assert_eq!(
BoxedAppError::from(::std::io::Error::new(::std::io::ErrorKind::Other, ""))
BoxedAppError::from(::std::io::Error::other(""))
.response()
.status(),
StatusCode::INTERNAL_SERVER_ERROR
Expand Down
2 changes: 1 addition & 1 deletion src/util/io_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn read_fill<R: Read + ?Sized>(r: &mut R, mut slice: &mut [u8]) -> io::Resul
while !slice.is_empty() {
let n = r.read(slice)?;
if n == 0 {
return Err(io::Error::new(io::ErrorKind::Other, "end of file reached"));
return Err(io::Error::other("end of file reached"));
}
slice = &mut mem::take(&mut slice)[n..];
}
Expand Down
Loading