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

Support both [[bin]] and [lib] together? #4

Closed
dpc opened this issue Nov 8, 2015 · 5 comments
Closed

Support both [[bin]] and [lib] together? #4

dpc opened this issue Nov 8, 2015 · 5 comments

Comments

@dpc
Copy link

dpc commented Nov 8, 2015

% cargo check
extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing e.g. `--lib` or `--bin NAME` to specify a single target

Isn't there any way to support both [[bin]] and [lib] in one go? cargo build just works, so I'd expect cargo check to be drop-in replacement.

@rsolomo
Copy link
Owner

rsolomo commented Nov 11, 2015

Yeah, this is the same error message that you'll receive if you ran cargo rustc -- -Zno-trans.

I normally work around this by doing something like cargo check --lib.
I'm not sure if there is a way to get cargo rustc to behave more like cargo build when it comes to this.

@dpc
Copy link
Author

dpc commented Nov 11, 2015

Maybe we should escalate to cargo devs?

@lily-mara
Copy link

The problem with always running cargo check --lib is that it excludes the main.rs file if you have one. This means that there currently isn't a way to run a generic cargo check command that will automatically build the project for editor linter support. A bit disappointing. I suppose I'll go back to cargo build.

@HybridEidolon
Copy link

My workaround for this was to split my project into several crates, with the top-level crate being bin-only and the rest being libs. However, this means that you have to append -p to your check invocation to lint the other crates.

@bruno-medeiros
Copy link

And what about the test targets... I wanna check those too. 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants