Skip to content

Commit

Permalink
Better debug logging in flycheck
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Sep 4, 2024
1 parent dc85a4d commit 52354dc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub(crate) enum Progress {
DidFailToRestart(String),
}

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

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

let Some((command, origin)) =
self.check_command(package, saved_file.as_deref(), target)
self.check_command(package.clone(), saved_file.as_deref(), target)
else {
tracing::debug!(?package, "failed to build flycheck command");
continue;
};

Expand All @@ -429,19 +430,19 @@ impl FlycheckActor {
),
};

tracing::debug!(?command, "will restart flycheck");
tracing::debug!(?origin, ?command, "will restart flycheck");
let (sender, receiver) = unbounded();
match CommandHandle::spawn(command, sender) {
Ok(command_handle) => {
tracing::debug!(command = debug_command, "did restart flycheck");
tracing::debug!(?origin, command = %debug_command, "did restart flycheck");
self.command_handle = Some(command_handle);
self.command_receiver = Some(receiver);
self.report_progress(Progress::DidStart { user_facing_command });
self.status = FlycheckStatus::Started;
}
Err(error) => {
self.report_progress(Progress::DidFailToRestart(format!(
"Failed to run the following command: {debug_command} error={error}"
"Failed to run the following command: {debug_command} origin={origin:?} error={error}"
)));
self.status = FlycheckStatus::Finished;
}
Expand Down

0 comments on commit 52354dc

Please sign in to comment.