Skip to content

Commit

Permalink
Resolve new clippy warnings (pyca#10755)
Browse files Browse the repository at this point in the history
The fixes themselves are of marginal value 🙃
  • Loading branch information
alex committed May 4, 2024
1 parent 9742c0c commit 8802c7e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
17 changes: 12 additions & 5 deletions src/rust/src/x509/crl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,18 @@ fn try_map_arc_data_mut_crl_iterator<E>(
) -> Result<crl::RevokedCertificate<'this>, E>,
) -> Result<OwnedRevokedCertificate, E> {
OwnedRevokedCertificate::try_new(Arc::clone(it.borrow_owner()), |inner_it| {
// SAFETY: This is safe because `Arc::clone` ensures the data is
// alive, but Rust doesn't understand the lifetime relationship it
// produces. Open-coded implementation of the API discussed in
// https://github.com/joshua-maros/ouroboros/issues/38
it.with_dependent_mut(|_, value| f(inner_it, unsafe { std::mem::transmute(value) }))
it.with_dependent_mut(|_, value| {
// SAFETY: This is safe because `Arc::clone` ensures the data is
// alive, but Rust doesn't understand the lifetime relationship it
// produces. Open-coded implementation of the API discussed in
// https://github.com/joshua-maros/ouroboros/issues/38
f(inner_it, unsafe {
std::mem::transmute::<
&mut Option<asn1::SequenceOf<'_, crl::RevokedCertificate<'_>>>,
&mut Option<asn1::SequenceOf<'_, crl::RevokedCertificate<'_>>>,
>(value)
})
})
})
}

Expand Down
23 changes: 17 additions & 6 deletions src/rust/src/x509/ocsp_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ fn map_arc_data_ocsp_response(
// alive, but Rust doesn't understand the lifetime relationship it
// produces. Open-coded implementation of the API discussed in
// https://github.com/joshua-maros/ouroboros/issues/38
f(inner_it.as_bytes(py), unsafe { std::mem::transmute(value) })
f(inner_it.as_bytes(py), unsafe {
std::mem::transmute::<&ocsp_resp::OCSPResponse<'_>, &ocsp_resp::OCSPResponse<'_>>(
value,
)
})
})
})
}
Expand All @@ -430,11 +434,18 @@ fn try_map_arc_data_mut_ocsp_response_iterator<E>(
) -> Result<ocsp_resp::SingleResponse<'this>, E>,
) -> Result<OwnedSingleResponse, E> {
OwnedSingleResponse::try_new(Arc::clone(it.borrow_owner()), |inner_it| {
// SAFETY: This is safe because `Arc::clone` ensures the data is
// alive, but Rust doesn't understand the lifetime relationship it
// produces. Open-coded implementation of the API discussed in
// https://github.com/joshua-maros/ouroboros/issues/38
it.with_dependent_mut(|_, value| f(inner_it, unsafe { std::mem::transmute(value) }))
it.with_dependent_mut(|_, value| {
// SAFETY: This is safe because `Arc::clone` ensures the data is
// alive, but Rust doesn't understand the lifetime relationship it
// produces. Open-coded implementation of the API discussed in
// https://github.com/joshua-maros/ouroboros/issues/38
f(inner_it, unsafe {
std::mem::transmute::<
&mut asn1::SequenceOf<'_, ocsp_resp::SingleResponse<'_>>,
&mut asn1::SequenceOf<'_, ocsp_resp::SingleResponse<'_>>,
>(value)
})
})
})
}

Expand Down

0 comments on commit 8802c7e

Please sign in to comment.