@@ -206,36 +206,32 @@ impl<VatId> QuestionRef<VatId> {
206
206
impl < VatId > Drop for QuestionRef < VatId > {
207
207
fn drop ( & mut self ) {
208
208
let mut questions = self . connection_state . questions . borrow_mut ( ) ;
209
- match & mut questions. slots [ self . id as usize ] {
210
- Some ( q) => {
211
- if let Ok ( ref mut c) = * self . connection_state . connection . borrow_mut ( ) {
212
- let mut message = c. new_outgoing_message ( 5 ) ;
213
- {
214
- let root: message:: Builder = message. get_body ( ) . unwrap ( ) . init_as ( ) ;
215
- let mut builder = root. init_finish ( ) ;
216
- builder. set_question_id ( self . id ) ;
217
-
218
- // If we're still awaiting a return, then this request is being
219
- // canceled, and we're going to ignore any capabilities in the return
220
- // message, so set releaseResultCaps true. If we already received the
221
- // return, then we've already built local proxies for the caps and will
222
- // send Release messages when those are destroyed.
223
- builder. set_release_result_caps ( q. is_awaiting_return ) ;
224
- }
225
- let _ = message. send ( ) ;
226
- }
209
+ let Some ( q) = & mut questions. slots [ self . id as usize ] else {
210
+ unreachable ! ( )
211
+ } ;
212
+ if let Ok ( ref mut c) = * self . connection_state . connection . borrow_mut ( ) {
213
+ let mut message = c. new_outgoing_message ( 5 ) ;
214
+ {
215
+ let root: message:: Builder = message. get_body ( ) . unwrap ( ) . init_as ( ) ;
216
+ let mut builder = root. init_finish ( ) ;
217
+ builder. set_question_id ( self . id ) ;
227
218
228
- if q. is_awaiting_return {
229
- // Still waiting for return, so just remove the QuestionRef pointer from the table.
230
- q. self_ref = None ;
231
- } else {
232
- // Call has already returned, so we can now remove it from the table.
233
- questions. erase ( self . id )
234
- }
235
- }
236
- None => {
237
- unreachable ! ( )
219
+ // If we're still awaiting a return, then this request is being
220
+ // canceled, and we're going to ignore any capabilities in the return
221
+ // message, so set releaseResultCaps true. If we already received the
222
+ // return, then we've already built local proxies for the caps and will
223
+ // send Release messages when those are destroyed.
224
+ builder. set_release_result_caps ( q. is_awaiting_return ) ;
238
225
}
226
+ let _ = message. send ( ) ;
227
+ }
228
+
229
+ if q. is_awaiting_return {
230
+ // Still waiting for return, so just remove the QuestionRef pointer from the table.
231
+ q. self_ref = None ;
232
+ } else {
233
+ // Call has already returned, so we can now remove it from the table.
234
+ questions. erase ( self . id )
239
235
}
240
236
}
241
237
}
@@ -554,27 +550,25 @@ impl<VatId> ConnectionState<VatId> {
554
550
555
551
let connection = mem:: replace ( & mut * self . connection . borrow_mut ( ) , Err ( error. clone ( ) ) ) ;
556
552
557
- match connection {
558
- Ok ( mut c) => {
559
- let promise = c. shutdown ( Err ( error) ) . then ( |r| match r {
560
- Ok ( ( ) ) => Promise :: ok ( ( ) ) ,
561
- Err ( e) => {
562
- if e. kind != :: capnp:: ErrorKind :: Disconnected {
563
- // Don't report disconnects as an error.
564
- Promise :: err ( e)
565
- } else {
566
- Promise :: ok ( ( ) )
567
- }
568
- }
569
- } ) ;
570
- match self . disconnect_fulfiller . borrow_mut ( ) . take ( ) {
571
- None => unreachable ! ( ) ,
572
- Some ( fulfiller) => {
573
- let _ = fulfiller. send ( Promise :: from_future ( promise. attach ( c) ) ) ;
574
- }
553
+ let Ok ( mut c) = connection else {
554
+ unreachable ! ( )
555
+ } ;
556
+ let promise = c. shutdown ( Err ( error) ) . then ( |r| match r {
557
+ Ok ( ( ) ) => Promise :: ok ( ( ) ) ,
558
+ Err ( e) => {
559
+ if e. kind != :: capnp:: ErrorKind :: Disconnected {
560
+ // Don't report disconnects as an error.
561
+ Promise :: err ( e)
562
+ } else {
563
+ Promise :: ok ( ( ) )
575
564
}
576
565
}
577
- Err ( _) => unreachable ! ( ) ,
566
+ } ) ;
567
+ match self . disconnect_fulfiller . borrow_mut ( ) . take ( ) {
568
+ None => unreachable ! ( ) ,
569
+ Some ( fulfiller) => {
570
+ let _ = fulfiller. send ( Promise :: from_future ( promise. attach ( c) ) ) ;
571
+ }
578
572
}
579
573
}
580
574
@@ -1398,14 +1392,10 @@ impl<VatId> ConnectionState<VatId> {
1398
1392
if contains_key {
1399
1393
// We've already seen and exported this capability before. Just up the refcount.
1400
1394
let export_id = state. exports_by_cap . borrow ( ) [ & ptr] ;
1401
- match state. exports . borrow_mut ( ) . find ( export_id) {
1402
- None => unreachable ! ( ) ,
1403
- Some ( exp) => {
1404
- descriptor. set_sender_hosted ( export_id) ;
1405
- exp. refcount += 1 ;
1406
- Ok ( Some ( export_id) )
1407
- }
1408
- }
1395
+ descriptor. set_sender_hosted ( export_id) ;
1396
+ // Should never fail because exports_by_cap should match exports.
1397
+ state. exports . borrow_mut ( ) . find ( export_id) . unwrap ( ) . refcount += 1 ;
1398
+ Ok ( Some ( export_id) )
1409
1399
} else {
1410
1400
// This is the first time we've seen this capability.
1411
1401
0 commit comments