@@ -359,7 +359,7 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
359
359
while let Some ( key) = map. next_key ( ) ? {
360
360
match key {
361
361
"id" => {
362
- id = Some ( map. next_value ( ) ?) ;
362
+ id = map. next_value ( ) ?;
363
363
}
364
364
"method" => {
365
365
method = Some ( map. next_value ( ) ?) ;
@@ -379,8 +379,16 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
379
379
}
380
380
}
381
381
382
- match ( id, method) {
383
- ( Some ( id) , Some ( method) ) => match method {
382
+ let id = id. ok_or_else ( || {
383
+ if let Some ( method) = method {
384
+ de:: Error :: custom ( format ! ( "Received unknown notification: {}" , method) )
385
+ } else {
386
+ de:: Error :: custom ( "Received invalid JSON-RPC object: one of method or id required" )
387
+ }
388
+ } ) ?;
389
+
390
+ match method {
391
+ Some ( method) => match method {
384
392
LSPS0_LISTPROTOCOLS_METHOD_NAME => {
385
393
self . request_id_to_method . insert ( id. clone ( ) , method. to_string ( ) ) ;
386
394
@@ -437,7 +445,7 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
437
445
method
438
446
) ) ) ,
439
447
} ,
440
- ( Some ( id ) , None ) => match self . request_id_to_method . get ( & id) {
448
+ None => match self . request_id_to_method . get ( & id) {
441
449
Some ( method) => match method. as_str ( ) {
442
450
LSPS0_LISTPROTOCOLS_METHOD_NAME => {
443
451
if let Some ( error) = error {
@@ -536,12 +544,6 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
536
544
id
537
545
) ) ) ,
538
546
} ,
539
- ( None , Some ( method) ) => {
540
- Err ( de:: Error :: custom ( format ! ( "Received unknown notification: {}" , method) ) )
541
- }
542
- ( None , None ) => Err ( de:: Error :: custom (
543
- "Received invalid JSON-RPC object: one of method or id required" ,
544
- ) ) ,
545
547
}
546
548
}
547
549
}
0 commit comments