diff options
| author | bors <bors@rust-lang.org> | 2023-08-08 13:23:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-08 13:23:21 +0000 |
| commit | ed4e28b2db7c058a39b498b5524e76f1188a4525 (patch) | |
| tree | d42c610c6d006bde4c4d9585e212b457eaf9ebb0 | |
| parent | f98d654ddf9be78384a7d8a9b707fb1bca9be48e (diff) | |
| parent | 02d5c0ac56fd8a89cade6dd83cfd122c6adec691 (diff) | |
| download | rust-ed4e28b2db7c058a39b498b5524e76f1188a4525.tar.gz rust-ed4e28b2db7c058a39b498b5524e76f1188a4525.zip | |
Auto merge of #15217 - Sarrus1:fix/unsafe-unwrap, r=Veykril
internal: convert unwrap to except and add a debug log Remove an unsafe unwrap that can cause crashes if the value is a `SendError`. This is my first PR on this repo, please let me know if there is anything I can improve or details I can provide.
| -rw-r--r-- | lib/lsp-server/src/stdio.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/lsp-server/src/stdio.rs b/lib/lsp-server/src/stdio.rs index 49a825e579b..e487b9b4622 100644 --- a/lib/lsp-server/src/stdio.rs +++ b/lib/lsp-server/src/stdio.rs @@ -3,6 +3,8 @@ use std::{ thread, }; +use log::debug; + use crossbeam_channel::{bounded, Receiver, Sender}; use crate::Message; @@ -23,7 +25,8 @@ pub(crate) fn stdio_transport() -> (Sender<Message>, Receiver<Message>, IoThread while let Some(msg) = Message::read(&mut stdin)? { let is_exit = matches!(&msg, Message::Notification(n) if n.is_exit()); - reader_sender.send(msg).unwrap(); + debug!("sending message {:#?}", msg); + reader_sender.send(msg).expect("receiver was dropped, failed to send a message"); if is_exit { break; |
