mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #8187 - alexcrichton:less-loop, r=ehuss
Remove unnecessary loop in `maybe_spurious` The `anyhow` library's error already does a recursive check when we use `Error::downcast_ref`, so there's no need to explicitly do this on the `chain` of errors.
This commit is contained in:
commit
258c89644c
@ -34,31 +34,29 @@ impl<'a> Retry<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_spurious(err: &Error) -> bool {
|
fn maybe_spurious(err: &Error) -> bool {
|
||||||
for e in err.chain() {
|
if let Some(git_err) = err.downcast_ref::<git2::Error>() {
|
||||||
if let Some(git_err) = e.downcast_ref::<git2::Error>() {
|
match git_err.class() {
|
||||||
match git_err.class() {
|
git2::ErrorClass::Net | git2::ErrorClass::Os => return true,
|
||||||
git2::ErrorClass::Net | git2::ErrorClass::Os => return true,
|
_ => (),
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if let Some(curl_err) = e.downcast_ref::<curl::Error>() {
|
}
|
||||||
if curl_err.is_couldnt_connect()
|
if let Some(curl_err) = err.downcast_ref::<curl::Error>() {
|
||||||
|| curl_err.is_couldnt_resolve_proxy()
|
if curl_err.is_couldnt_connect()
|
||||||
|| curl_err.is_couldnt_resolve_host()
|
|| curl_err.is_couldnt_resolve_proxy()
|
||||||
|| curl_err.is_operation_timedout()
|
|| curl_err.is_couldnt_resolve_host()
|
||||||
|| curl_err.is_recv_error()
|
|| curl_err.is_operation_timedout()
|
||||||
|| curl_err.is_http2_error()
|
|| curl_err.is_recv_error()
|
||||||
|| curl_err.is_http2_stream_error()
|
|| curl_err.is_http2_error()
|
||||||
|| curl_err.is_ssl_connect_error()
|
|| curl_err.is_http2_stream_error()
|
||||||
|| curl_err.is_partial_file()
|
|| curl_err.is_ssl_connect_error()
|
||||||
{
|
|| curl_err.is_partial_file()
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
if let Some(not_200) = e.downcast_ref::<HttpNot200>() {
|
}
|
||||||
if 500 <= not_200.code && not_200.code < 600 {
|
if let Some(not_200) = err.downcast_ref::<HttpNot200>() {
|
||||||
return true;
|
if 500 <= not_200.code && not_200.code < 600 {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user