Skip to content

Commit c09a43e

Browse files
committed
still more clippy
1 parent 7fab1cb commit c09a43e

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

capnp-rpc/src/rpc.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,9 @@ fn remote_exception_to_error(exception: exception::Reader) -> Error {
381381
}
382382
_ => (::capnp::ErrorKind::Failed, "(malformed error)".into()),
383383
};
384-
let reason_str = match reason.to_str() {
385-
Ok(s) => s,
386-
Err(_) => "<malformed utf-8 in error reason>",
387-
};
384+
let reason_str = reason
385+
.to_str()
386+
.unwrap_or("<malformed utf-8 in error reason>");
388387
Error {
389388
extra: format!("remote exception: {reason_str}"),
390389
kind,
@@ -570,9 +569,7 @@ impl<VatId> ConnectionState<VatId> {
570569
}
571570
}
572571
});
573-
let maybe_fulfiller =
574-
mem::replace(&mut *self.disconnect_fulfiller.borrow_mut(), None);
575-
match maybe_fulfiller {
572+
match self.disconnect_fulfiller.borrow_mut().take() {
576573
None => unreachable!(),
577574
Some(fulfiller) => {
578575
let _ = fulfiller.send(Promise::from_future(promise.attach(c)));

capnp-rpc/src/twoparty.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ where
104104
T: AsyncRead,
105105
{
106106
fn drop(&mut self) {
107-
let maybe_fulfiller = ::std::mem::replace(&mut self.on_disconnect_fulfiller, None);
108-
match maybe_fulfiller {
107+
match self.on_disconnect_fulfiller.take() {
109108
Some(fulfiller) => {
110109
let _ = fulfiller.send(());
111110
}
@@ -162,7 +161,7 @@ where
162161
) -> Promise<Option<Box<dyn crate::IncomingMessage + 'static>>, ::capnp::Error> {
163162
let inner = self.inner.borrow_mut();
164163

165-
let maybe_input_stream = ::std::mem::replace(&mut *inner.input_stream.borrow_mut(), None);
164+
let maybe_input_stream = inner.input_stream.borrow_mut().take();
166165
let return_it_here = inner.input_stream.clone();
167166
match maybe_input_stream {
168167
Some(mut s) => {
@@ -279,8 +278,7 @@ where
279278
}
280279

281280
fn accept(&mut self) -> Promise<Box<dyn crate::Connection<VatId>>, ::capnp::Error> {
282-
let connection = ::std::mem::replace(&mut self.connection, None);
283-
match connection {
281+
match self.connection.take() {
284282
Some(c) => Promise::ok(Box::new(c) as Box<dyn crate::Connection<VatId>>),
285283
None => Promise::from_future(::futures::future::pending()),
286284
}

capnp/src/private/layout.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl WirePointer {
159159
}
160160

161161
#[inline]
162-
pub fn target(ptr: *const Self) -> *const u8 {
162+
pub unsafe fn target(ptr: *const Self) -> *const u8 {
163163
let this_addr: *const u8 = ptr as *const _;
164164
unsafe { this_addr.offset(8 * (1 + (((*ptr).offset_and_kind.get() as i32) >> 2)) as isize) }
165165
}
@@ -2036,18 +2036,14 @@ mod wire_helpers {
20362036
// in the canonicalize=true case.
20372037
let whole_byte_size =
20382038
u64::from(value.element_count) * u64::from(value.step) / BITS_PER_BYTE as u64;
2039-
ptr::copy_nonoverlapping(
2040-
value.ptr as *const u8,
2041-
ptr as *mut u8,
2042-
whole_byte_size as usize,
2043-
);
2039+
ptr::copy_nonoverlapping(value.ptr, ptr, whole_byte_size as usize);
20442040
let leftover_bits =
20452041
u64::from(value.element_count) * u64::from(value.step) % BITS_PER_BYTE as u64;
20462042
if leftover_bits > 0 {
20472043
let mask: u8 = (1 << leftover_bits as u8) - 1;
20482044

20492045
*ptr.offset(whole_byte_size as isize) =
2050-
mask & (*(value.ptr as *const u8).offset(whole_byte_size as isize))
2046+
mask & (*value.ptr.offset(whole_byte_size as isize))
20512047
}
20522048
}
20532049

0 commit comments

Comments
 (0)