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

Add variable to fix rust-cargo error for multiple targets #958

Closed
wants to merge 3 commits into from
Closed

Add variable to fix rust-cargo error for multiple targets #958

wants to merge 3 commits into from

Conversation

fmdkdd
Copy link
Member

@fmdkdd fmdkdd commented May 7, 2016

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.

fmdkdd added 2 commits May 7, 2016 17:27
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"))
Copy link
Contributor

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?

Copy link
Member Author

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
@swsnr swsnr self-assigned this May 9, 2016
@swsnr
Copy link
Contributor

swsnr commented May 9, 2016

@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?

@fmdkdd
Copy link
Member Author

fmdkdd commented May 10, 2016

@lunaryorn My alias is fine, if that's ok with you.

@swsnr
Copy link
Contributor

swsnr commented May 10, 2016

@fmdkdd Sure.

@swsnr
Copy link
Contributor

swsnr commented May 10, 2016

@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.

@fmdkdd
Copy link
Member Author

fmdkdd commented May 10, 2016

@lunaryorn Thank you for the invitation. I will take a look at the guides and do my best to lend a hand.

@swsnr
Copy link
Contributor

swsnr commented May 10, 2016

@fmdkdd Great, awesome to have you on board! /cc @flycheck/maintainers

@fmdkdd fmdkdd deleted the rust-cargo-fix branch May 10, 2016 20:03
swsnr pushed a commit to flycheck/flycheck-rust that referenced this pull request May 11, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants