Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flycheck: initial implementation of $saved_file #15381

Conversation

davidbarsky
Copy link
Contributor

I don't think this is the cleanest or best code I've ever written, but paired with the changes in facebook/buck2@8410bca0dda8a499065c4651774c33b7143c4983—which I've been using personally for the last week or so—this solution works pretty nicely. This PR takes inspiration from #13528 and implements the "potential solution" in outlined in #12882.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 2, 2023
@davidbarsky davidbarsky force-pushed the davidbarsky/implement-saved-file branch from 6c36c2c to 397fed5 Compare August 11, 2023 14:24
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to check up with my old related PR (that you've linked) to see if this works out together later,

Implements the "potential solution" in outlined in #12882.

I don't see where this is related. The PR here merely implements the logic for helping out non cargo based build tools.

Comment on lines +76 to +80
match self {
FlycheckConfig::CustomCommand { invoke_with_saved_file, .. } => *invoke_with_saved_file,
_ => false,
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
match self {
FlycheckConfig::CustomCommand { invoke_with_saved_file, .. } => *invoke_with_saved_file,
_ => false,
}
}
matches!(self, FlycheckConfig::CustomCommand { invoke_with_saved_file: true, .. })
}

@@ -163,6 +174,7 @@ struct FlycheckActor {
/// Either the workspace root of the workspace we are flychecking,
/// or the project root of the project.
root: AbsPathBuf,
state: OnceCell<FlycheckState>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for having this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It solves a cancellation-related bug: a flycheck would be started, canceled before completion, and restarted. The restarted flycheck would then not interpolate the $saved_file value.

I think with some deeper changes to Flycheck, this can be replaced by a last_saved_file, but this introduction of statefulness one reason I have some misgivings about this approach.

@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2023
@davidbarsky
Copy link
Contributor Author

I'll have to check up with my old related PR (that you've linked) to see if this works out together later,

I get some not-great vibes from this implementation. It might work, but there's a messiness here that's bothering me.

Implements the "potential solution" in outlined in #12882.

I don't see where this is related. The PR here merely implements the logic for helping out non cargo based build tools.

I believe I was referring to the $saved_file business, but I'll need to double-check.

@Veykril
Copy link
Member

Veykril commented Aug 15, 2023

Ah you meant to link #13437 then I think

@Veykril
Copy link
Member

Veykril commented Aug 15, 2023

I get some not-great vibes from this implementation. It might work, but there's a messiness here that's bothering me.

I'll have to give this topic another look in 2 weeks then probably (kind of exhausted most of my general r-a budget this week and then I'm on vacation) .

@davidbarsky
Copy link
Contributor Author

I get some not-great vibes from this implementation. It might work, but there's a messiness here that's bothering me.

I'll have to give this topic another look in 2 weeks then probably (kind of exhausted most of my general r-a budget this week and then I'm on vacation) .

No worries, enjoy your vacation! I'm going to think about this approach during this time.

@bors
Copy link
Contributor

bors commented Aug 29, 2023

☔ The latest upstream changes (presumably #15465) made this pull request unmergeable. Please resolve the merge conflicts.

@Veykril Veykril self-assigned this Sep 23, 2023
@davidbarsky
Copy link
Contributor Author

I'm going to close this in favor of #15476 (Wilfred and I work together).

@davidbarsky davidbarsky closed this Nov 2, 2023
@davidbarsky davidbarsky deleted the davidbarsky/implement-saved-file branch November 2, 2023 19:52
bors added a commit that referenced this pull request Feb 12, 2024
Substitute $saved_file in custom check commands

If the custom command has a $saved_file placeholder, and we know the file being saved, replace the placeholder and run a check command.

If there's a placeholder and we don't know the saved file, do nothing.

This is a simplified version of #15381, which I hope is easier to review.
bors added a commit that referenced this pull request Feb 12, 2024
Substitute $saved_file in custom check commands

If the custom command has a $saved_file placeholder, and we know the file being saved, replace the placeholder and run a check command.

If there's a placeholder and we don't know the saved file, do nothing.

This is a simplified version of #15381, which I hope is easier to review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants