-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Minimum rustc version error #449
Minimum rustc version error #449
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR, it's super helpful and I'm excited to merge it soon.
I have a couple of suggestions to make it even better.
@@ -0,0 +1,2 @@ | |||
[toolchain] | |||
channel = "1.64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I think the way our tests are set up will explicitly ignore this.
It might be less work to write this test as a GitHub Action job. That way we don't have to change how the test setup works, and people don't have to keep Rust 1.64 installed just to run tests locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I managed to have the test actually use the 1.64
channel automatically. However I agree that forcing people to have Rust 1.64 installed is pretty annoying.
My original idea was that it would catch bumps of the minimal version, so that the error detection + message might be updated. But looking at it now, I guess such a bump would fail CI anyway, and it would make it clear that the check rust_version < rustc_version_1_65
must be updated... I think ?
So, should I remove the tests entirely ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the tests here but then set up an equivalent test in GitHub Actions, where it explicitly uses Rust 1.64 to semver-check a crate, captures the output, and asserts the exit code was non-zero and contained the warning about using an old Rust.
There are some tests like that in GitHub Actions already, and you should be able to do what they do as well.
c9c25bd
to
4193e67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality-wise this looks good. Just a couple of wording suggestions in the error messages and the test tweaks.
src/lib.rs
Outdated
config.shell_warn(format_args!( | ||
"while trying to query the current rustc version: {}", | ||
error | ||
))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message text is "implementation-oriented." The user that would see it wouldn't know we were querying the rustc version (or why) so they'll just be confused and won't know what to do. Let's try to make this a user-oriented, actionable error message:
config.shell_warn(format_args!( | |
"while trying to query the current rustc version: {}", | |
error | |
))?; | |
config.shell_warn(format_args!( | |
"failed to determine the current rustc version: {}\n\nHELP: to avoid errors please ensure Rust 1.65+ is used", | |
error | |
))?; |
or something to that effect. Bonus points if you could pull the rustc_version_needed
into config
itself and then somehow use its value to generate the "Rust 1.65+" portion of the error message string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does pulling the rustc_version_needed
into config
bring other benefits? Right now the message is generated by the local let rustc_version_needed = rustc_version::Version::new(1, 65, 0)
, and it works well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This local let
is unfortunately not authoritative on which version is actually supported — it's totally possible that we bump the underlying trustfall_rustdoc
dependency (which is authoritative on the supported rustdoc versions) while forgetting to change this value here.
It's somewhat less likely that we forget it if it's either a global static, or in the config, than a random local variable in the middle of the file. So it's just about improving the probability of us remembering to change it, nothing else :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
@@ -0,0 +1,2 @@ | |||
[toolchain] | |||
channel = "1.64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the tests here but then set up an equivalent test in GitHub Actions, where it explicitly uses Rust 1.64 to semver-check a crate, captures the output, and asserts the exit code was non-zero and contained the warning about using an old Rust.
There are some tests like that in GitHub Actions already, and you should be able to do what they do as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality-wise this looks good. Just a couple of wording suggestions in the error messages and the test tweaks.
5b386e0
to
67433b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test looks great. Just a couple of minor nits left.
I'll fix the nightly problem tomorrow or on Monday, don't worry about it for now. It isn't required to pass to merge PRs.
src/lib.rs
Outdated
@@ -316,6 +316,26 @@ impl Check { | |||
.deps(false) | |||
.silence(!config.is_verbose()); | |||
|
|||
// If both the current and baseline rustdoc are given explicitely as a file path, we don't need to use the installed rustc, and this check can be skipped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If both the current and baseline rustdoc are given explicitely as a file path, we don't need to use the installed rustc, and this check can be skipped. | |
// If both the current and baseline rustdoc are given explicitly as a file path, we don't need to use the installed rustc, and this check can be skipped. |
Typo fix + let's try to keep comments and string literals to below 100 chars both here and below
src/lib.rs
Outdated
if !(matches!(self.current.source, RustdocSource::Rustdoc(_)) | ||
&& matches!(self.baseline.source, RustdocSource::Rustdoc(_))) | ||
{ | ||
let rustc_version_needed = rustc_version::Version::new(1, 65, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can lift this to a global static (ideally) or into the global config (next best), that'd be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test looks great. Just a couple of minor nits left.
I'll fix the nightly problem tomorrow or on Monday, don't worry about it for now. It isn't required to pass to merge PRs.
67433b2
to
deafd14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for all the help!
If you might be interested in continuing to contribute to the project, we could certainly use the help! #451 in particular is an unfortunate (and kind of embarrassing) issue that shouldn't be too hard to fix. The full list of contributor-friendly issues is here: https://github.com/obi1kenobi/cargo-semver-checks/issues?q=is%3Aissue+is%3Aopen+label%3AE-help-wanted |
Head branch was pushed to by a user without write access
ee1a37f
to
122ff4d
Compare
Add an error when the user is running cargo-semver-checks with a rustc version
< 1.65
.