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 variable to fix rust-cargo error for multiple targets #958
Conversation
Error reports from rustc have changed again (see GH-592). I updated the test to match the new format.
When there are multiple targets, we should call `cargo rustc --bin NAME` with NAME being the binary name to build. This new variable allows one to set the binary name. rust-cargo will only use it when `flycheck-rust-crate-type` is `bin`. If it is unset, we fallback to the previous behavior of not using `--bin`, to let cargo build the default binary.
`bin' and there are multiple binary targets." | ||
:type 'string | ||
:safe #'stringp | ||
:package-version '("flycheck" . "0.28")) |
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 version would be 27 here.
If I may ask, why did you use 0.28 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 misinterpreted 0.27snapshot as being before the 0.28 release.
- Rewording of the docstring - Change package-version to 0.27 - Use `cond` instead of nested `if`s - Remove unnecessary variable in 'warning' test
@fmdkdd Ah, I wanted to merge this, but I noticed that your Github profile name is the same as your Github nickname, and I wondered under which name to our contributor's list. Your Github alias, or would you rather like to appear under a different name? |
@lunaryorn My alias is fine, if that's ok with you. |
@fmdkdd Sure. |
@fmdkdd I've merged this change, and will soon merge the corresponding PR to flycheck-rust. I've sent you an invitation to our Github org which gives you push access to this repo and to flycheck-rust. Please take a look at our Contributor's Guide and our Maintainer's Guide to see how we work and what guidelines to follow when pushing to Flycheck. |
@lunaryorn Thank you for the invitation. I will take a look at the guides and do my best to lend a hand. |
@fmdkdd Great, awesome to have you on board! /cc @flycheck/maintainers |
When both 'src/lib.rs' and 'src/main.rs' are present in the project, we default to invoking `cargo rustc`. This command requires an explicit binary name with the `--bin` flag, otherwise it causes the error described in GH-23. This commit adds logic to parse the output of `cargo read-manifest` to determine the target type to check, based on the buffer file name. If the file name matches one of the targets, this target is chosen. Otherwise, the first target is chosen as a default. If the target is a binary, we also extract the binary name and set a new `flycheck-rust-binary-name` variable (see flycheck/flycheck#958) to solve the error. I've tested this work with 'src/main.rs' binaries as well as multiples binaries under 'src/bin'. Closes GH-25, fixes GH-23, and adds logic to tackle GH-8.
When multiple binary targets are present,
cargo rustc
requires the--bin NAME
option to filter the target to build, otherwise it errs.This variable allows one to specify the binary to build for projects that have multiple targets. If it is unset, we fallback to the previous behavior of not passing
--bin
, so it shouldn't break anything.And I've also updated the 'multiline-error' test, which failed because rustc updated its syntax.