Skip to content

Commit 52354dc

Browse files
committed
Better debug logging in flycheck
1 parent dc85a4d commit 52354dc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

crates/rust-analyzer/src/flycheck.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub(crate) enum Progress {
232232
DidFailToRestart(String),
233233
}
234234

235-
#[derive(Debug)]
235+
#[derive(Debug, Clone)]
236236
enum PackageToRestart {
237237
All,
238238
// Either a cargo package or a $label in rust-project.check.overrideCommand
@@ -249,7 +249,7 @@ enum FlycheckCommandOrigin {
249249
ProjectJsonRunnable,
250250
}
251251

252-
#[derive(Debug)]
252+
#[derive(Debug, Clone)]
253253
pub(crate) enum PackageSpecifier {
254254
Cargo {
255255
/// The one in Cargo.toml, assumed to work with `cargo check -p {}` etc
@@ -413,8 +413,9 @@ impl FlycheckActor {
413413
}
414414

415415
let Some((command, origin)) =
416-
self.check_command(package, saved_file.as_deref(), target)
416+
self.check_command(package.clone(), saved_file.as_deref(), target)
417417
else {
418+
tracing::debug!(?package, "failed to build flycheck command");
418419
continue;
419420
};
420421

@@ -429,19 +430,19 @@ impl FlycheckActor {
429430
),
430431
};
431432

432-
tracing::debug!(?command, "will restart flycheck");
433+
tracing::debug!(?origin, ?command, "will restart flycheck");
433434
let (sender, receiver) = unbounded();
434435
match CommandHandle::spawn(command, sender) {
435436
Ok(command_handle) => {
436-
tracing::debug!(command = debug_command, "did restart flycheck");
437+
tracing::debug!(?origin, command = %debug_command, "did restart flycheck");
437438
self.command_handle = Some(command_handle);
438439
self.command_receiver = Some(receiver);
439440
self.report_progress(Progress::DidStart { user_facing_command });
440441
self.status = FlycheckStatus::Started;
441442
}
442443
Err(error) => {
443444
self.report_progress(Progress::DidFailToRestart(format!(
444-
"Failed to run the following command: {debug_command} error={error}"
445+
"Failed to run the following command: {debug_command} origin={origin:?} error={error}"
445446
)));
446447
self.status = FlycheckStatus::Finished;
447448
}

0 commit comments

Comments
 (0)