Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 03a7abc

Browse files
committed
Use Sender directly instead of a boxed closure
1 parent bee4926 commit 03a7abc

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub(crate) struct FlycheckHandle {
109109
impl FlycheckHandle {
110110
pub(crate) fn spawn(
111111
id: usize,
112-
sender: Box<dyn Fn(FlycheckMessage) + Send>,
112+
sender: Sender<FlycheckMessage>,
113113
config: FlycheckConfig,
114114
sysroot_root: Option<AbsPathBuf>,
115115
workspace_root: AbsPathBuf,
@@ -199,7 +199,7 @@ enum StateChange {
199199
struct FlycheckActor {
200200
/// The workspace id of this flycheck instance.
201201
id: usize,
202-
sender: Box<dyn Fn(FlycheckMessage) + Send>,
202+
sender: Sender<FlycheckMessage>,
203203
config: FlycheckConfig,
204204
manifest_path: Option<AbsPathBuf>,
205205
/// Either the workspace root of the workspace we are flychecking,
@@ -235,7 +235,7 @@ pub(crate) const SAVED_FILE_PLACEHOLDER: &str = "$saved_file";
235235
impl FlycheckActor {
236236
fn new(
237237
id: usize,
238-
sender: Box<dyn Fn(FlycheckMessage) + Send>,
238+
sender: Sender<FlycheckMessage>,
239239
config: FlycheckConfig,
240240
sysroot_root: Option<AbsPathBuf>,
241241
workspace_root: AbsPathBuf,
@@ -479,7 +479,7 @@ impl FlycheckActor {
479479
}
480480

481481
fn send(&self, check_task: FlycheckMessage) {
482-
(self.sender)(check_task);
482+
self.sender.send(check_task).unwrap();
483483
}
484484
}
485485

src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ impl GlobalState {
758758
self.flycheck = match invocation_strategy {
759759
crate::flycheck::InvocationStrategy::Once => vec![FlycheckHandle::spawn(
760760
0,
761-
Box::new(move |msg| sender.send(msg).unwrap()),
761+
sender,
762762
config,
763763
None,
764764
self.config.root_path().clone(),
@@ -793,10 +793,9 @@ impl GlobalState {
793793
))
794794
})
795795
.map(|(id, (root, manifest_path), sysroot_root)| {
796-
let sender = sender.clone();
797796
FlycheckHandle::spawn(
798797
id,
799-
Box::new(move |msg| sender.send(msg).unwrap()),
798+
sender.clone(),
800799
config.clone(),
801800
sysroot_root,
802801
root.to_path_buf(),

0 commit comments

Comments
 (0)