-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add support for 'required-features'. #69
Add support for 'required-features'. #69
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.
Good call on making an alist. It's probably more readable that way with multiple features.
Do you think you could add a test that gets the required-features
from a cargo project?
flycheck-rust.el
Outdated
kind (lib, bin, test, example or bench), and NAME the target | ||
name (usually, the crate name). If FILE-NAME exactly matches a | ||
target `src-path', this target is returned. Otherwise, return | ||
Return a alist ((KIND . k) (NAME . n) (REQUIRED-FEATURES . rf)) |
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.
Return an alist
flycheck-rust.el
Outdated
Return a alist ((KIND . k) (NAME . n) (REQUIRED-FEATURES . rf)) | ||
where KIND is the target kind (lib, bin, test, example or bench), | ||
NAME the target name (usually, the crate name), and REQUIRED-FEATURES is the | ||
optional list of features required to build selected target. If FILE-NAME |
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.
to build the selected target
6538525
to
24e0edd
Compare
@fmdkdd yeah, sure! Didn't want to add more code for tests without knowing it looks more or less ok %) Thanks for comments, fixed. |
Hm, tests are failing since cargo there doesn't have "required-features" in |
Shouldn't the nightly cargo already emit
The test will break for beta and stable, but should eventually get there. In the meantime, we should skip it for older versions. We can |
24e0edd
to
bb78041
Compare
@fmdkdd yeah, it's lagging behind Thanks! |
4ba335f
to
934bcb2
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.
Thanks. I have some stylistic changes, and one question about the actual version number. See the review comments.
tests/test-rust-setup.el
Outdated
:to-equal '((kind . "lib") (name . "lib-test")))) | ||
|
||
(it "'src/main.rs' to the bin target with required-features (fea1)" | ||
(if (cargo-older-than-1.29-nightly) |
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.
Better to use when
instead of an empty then
branch in the if
.
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.
True, will fix!
tests/test-rust-setup.el
Outdated
|
||
(defun get-cargo-version () | ||
(let ((cargo (funcall flycheck-executable-find "cargo"))) | ||
(with-temp-buffer |
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.
with-output-to-string
would be shorter here.
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 was looking for smth like that, cool, thanks.
tests/test-rust-setup.el
Outdated
|
||
(defun cargo-older-than-1.29-nightly () | ||
(let* ((version-parts (cargo-version)) | ||
(version (car version-parts)) |
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.
Can be shortened with:
(pcase-let ((`(,version ,channel) (cargo-version)))
...)
tests/test-rust-setup.el
Outdated
(let* ((version-parts (cargo-version)) | ||
(version (car version-parts)) | ||
(channel (cadr version-parts))) | ||
(if (version< version "1.29") |
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.
More idiomatic would be:
(or (version< version "1.29")
(and (version= version "1.29") (string= channel "beta")))
But wait, the name of the function implies we return t
when cargo --version
is more than 1.29-nightly, but we actually do the reverse. This should be fixed.
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.
Function name is cargo-version-is-older-than-1.29
, so for 1.28.0
it will return t
(1.28.0
came out before 1.29.0
, so it's older). Perhaps "older" is a bit confusing?
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.
Argh, excuse the brainfart. older
is not confusing at all, I was just confused.
tests/test-rust-setup.el
Outdated
(channel (cadr version-parts))) | ||
(if (version< version "1.29") | ||
t | ||
(and (version= version "1.29") (string= channel "beta"))))) |
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.
Do we actually know which version required-features
will be included in? If it's 1.30
, then we don't need to check for the channel, right?
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.
Current beta
has cargo 1.29.0-beta (<sha> 2018-08-05)
(or some such). Nighty should get this feature in a week at most, and the version will be 1.29.0-nightly (<sha> 2018-08-21)
. We can just test for 1.30
, but then we will disable test for nightly 1.29
even though cargo will have new feature.
Not a big deal, I guess, and will help make code a bit nicer.
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.
Ah sure, let's test with 1.29-nightly. No big deal.
Discover 'required-features' in Cargo manifest and initialize value of 'rust-cargo-features'.
934bcb2
to
7e491e9
Compare
Interesting! Thanks for keeping us posted.
Nope, LGTM. Good job and thank you for the contribution. 👏 |
Discover 'required-features' in Cargo manifest and initialize value of 'rust-cargo-features'. Fixes #68.