Skip to content

Commit df13e38

Browse files
authored
Merge pull request #11182 from rust-lang/renovate/rust-1.x
Update Rust to v1.87.0
2 parents 5194cd9 + 7978b29 commit df13e38

File tree

9 files changed

+23
-24
lines changed

9 files changed

+23
-24
lines changed

backend.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# renovate: datasource=github-tags depName=rust lookupName=rust-lang/rust
2-
ARG RUST_VERSION=1.86.0
2+
ARG RUST_VERSION=1.87.0
33

44
FROM rust:$RUST_VERSION
55

crates/crates_io_tarball/src/limit_reader.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ impl<R: AsyncRead + Unpin> AsyncRead for LimitErrorReader<R> {
2525
) -> Poll<io::Result<()>> {
2626
let reader = Pin::new(&mut self.inner);
2727
match reader.poll_read(cx, buf) {
28-
Poll::Ready(Ok(())) if self.inner.limit() == 0 => Poll::Ready(Err(io::Error::new(
29-
io::ErrorKind::Other,
30-
"maximum limit reached when reading",
31-
))),
28+
Poll::Ready(Ok(())) if self.inner.limit() == 0 => {
29+
Poll::Ready(Err(io::Error::other("maximum limit reached when reading")))
30+
}
3231
e => e,
3332
}
3433
}

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.86.0"
2+
channel = "1.87.0"

src/bin/crates-admin/render_readmes.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ async fn get_readme(
169169
));
170170
}
171171

172-
let reader = response
173-
.bytes_stream()
174-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e));
172+
let reader = response.bytes_stream().map_err(std::io::Error::other);
175173
let reader = StreamReader::new(reader);
176174
let reader = GzipDecoder::new(reader);
177175
let archive = Archive::new(reader);

src/controllers/krate/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const MAX_DESCRIPTION_LENGTH: usize = 1000;
6767
)]
6868
pub async fn publish(app: AppState, req: Parts, body: Body) -> AppResult<Json<GoodCrate>> {
6969
let stream = body.into_data_stream();
70-
let stream = stream.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err));
70+
let stream = stream.map_err(std::io::Error::other);
7171
let mut reader = StreamReader::new(stream);
7272

7373
// The format of the req.body() of a publish request is as follows:

src/middleware/block_traffic.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::app::AppState;
22
use crate::middleware::log_request::RequestLogExt;
33
use crate::middleware::real_ip::RealIp;
4-
use crate::util::errors::custom;
4+
use crate::util::errors::{BoxedAppError, custom};
55
use axum::extract::{Extension, MatchedPath, Request};
66
use axum::middleware::Next;
77
use axum::response::{IntoResponse, Response};
@@ -14,9 +14,9 @@ pub async fn middleware(
1414
req: Request,
1515
next: Next,
1616
) -> Result<impl IntoResponse, Response> {
17-
block_by_ip(&real_ip, &state, req.headers())?;
18-
block_by_header(&state, &req)?;
19-
block_routes(matched_path.as_ref(), &state)?;
17+
block_by_ip(&real_ip, &state, req.headers()).map_err(IntoResponse::into_response)?;
18+
block_by_header(&state, &req).map_err(IntoResponse::into_response)?;
19+
block_routes(matched_path.as_ref(), &state).map_err(IntoResponse::into_response)?;
2020

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

3535
for (header_name, blocked_values) in blocked_traffic {
@@ -53,15 +53,15 @@ pub fn block_by_ip(
5353
real_ip: &RealIp,
5454
state: &AppState,
5555
headers: &HeaderMap,
56-
) -> Result<(), Response> {
56+
) -> Result<(), impl IntoResponse> {
5757
if state.config.blocked_ips.contains(real_ip) {
5858
return Err(rejection_response_from(state, headers));
5959
}
6060

6161
Ok(())
6262
}
6363

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

6767
// Heroku should always set this header
@@ -77,17 +77,19 @@ fn rejection_response_from(state: &AppState, headers: &HeaderMap) -> Response {
7777
Please email help@crates.io and provide the request id {request_id}"
7878
);
7979

80-
(StatusCode::FORBIDDEN, body).into_response()
80+
(StatusCode::FORBIDDEN, body)
8181
}
8282

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

src/sentry/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mod tests {
113113
query_string: None,
114114
env: Default::default(),
115115
};
116-
let err = std::io::Error::new(std::io::ErrorKind::Other, "error");
116+
let err = std::io::Error::other("error");
117117

118118
let opts = options(SentryConfig::default());
119119
let event_req = req.clone();

src/util/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ mod tests {
311311
StatusCode::INTERNAL_SERVER_ERROR
312312
);
313313
assert_eq!(
314-
BoxedAppError::from(::std::io::Error::new(::std::io::ErrorKind::Other, ""))
314+
BoxedAppError::from(::std::io::Error::other(""))
315315
.response()
316316
.status(),
317317
StatusCode::INTERNAL_SERVER_ERROR

src/util/io_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn read_fill<R: Read + ?Sized>(r: &mut R, mut slice: &mut [u8]) -> io::Resul
1717
while !slice.is_empty() {
1818
let n = r.read(slice)?;
1919
if n == 0 {
20-
return Err(io::Error::new(io::ErrorKind::Other, "end of file reached"));
20+
return Err(io::Error::other("end of file reached"));
2121
}
2222
slice = &mut mem::take(&mut slice)[n..];
2323
}

0 commit comments

Comments
 (0)