Add variable to fix rust-cargo error for multiple targets #958
When multiple binary targets are present,
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
And I've also updated the 'multiline-error' test, which failed because rustc updated its syntax.
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.
@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.
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.