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

cargo check --all-targets can generate duplicate messages. #5561

Closed
mooman219 opened this issue May 23, 2018 · 2 comments
Closed

cargo check --all-targets can generate duplicate messages. #5561

mooman219 opened this issue May 23, 2018 · 2 comments

Comments

@mooman219
Copy link

mooman219 commented May 23, 2018

When running cargo check --all-targets, messages are sometimes duplicated in the output.

Version: cargo 1.27.0-nightly (9e53ac6 2018-05-07)

Example erroneous code in a simple new binary project:

fn main() {}

fn bar(foo: i32 bar: f32) -> f32 {
    return (foo as f32) + bar;
}

Corresponding output:

~/Downloads/test/vscode-test $ cargo check --all-targets
    Checking vscode-test v0.1.0 (file:///C:/Users/Mooma/Downloads/test/vscode-test)
error: expected one of `!`, `(`, `+`, `,`, `::`, or `<`, found `bar`
 --> src\main.rs:3:17
  |
3 | fn bar(foo: i32 bar: f32) -> f32 {
  |                 ^^^ expected one of `!`, `(`, `+`, `,`, `::`, or `<` here

error: expected one of `!`, `(`, `+`, `,`, `::`, or `<`, found `bar`
 --> src\main.rs:3:17
  |
3 | fn bar(foo: i32 bar: f32) -> f32 {
  |                 ^^^ expected one of `!`, `(`, `+`, `,`, `::`, or `<` here

error: aborting due to previous error

error: aborting due to previous error

error: Could not compile `vscode-test`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `vscode-test`.

To learn more, run the command again with --verbose.
@ehuss
Copy link
Contributor

ehuss commented May 23, 2018

The duplicates are due to the same file (main.rs in this case) being used for different targets (binary and unit test). You can use the various target flags (--bin, --lib, --test, etc.) to limit which targets are checked. It depends on your use case. I have my editor set up to automatically check as a test (cargo check --bin vscode-test --profile=test in this case) to ensure that any tests get checked (a few lints will be disabled, such as missing_docs when checking as a test, but those are rare).

@alexcrichton
Copy link
Member

What's actually happening here is that the library is being compiled twice (once with --test and once for doc tests later on), and this is a dupe of #1534, #851, and #1198. This is intended behavior though, and you can use various flags like --test, --lib, or -j to not run rustc in parallel, so I'm going to close this.

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

3 participants