-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 reissues warnings between builds for bin
crates, but not for lib
#3624
Comments
This former behavior is what I'd expect because the latter shows that the output is cached, which is definitely isn't! cc @nrc, I think we may be caching something and not rerunning perhaps? |
Any updates on this? I was hoping that the just released to stable |
I can try to make a PR, but any pointers as to where to look would be appreciated. |
@fmdkdd I'm not precisely sure where this would be located but it's pretty likely to be somewhere around |
I've taken a quick look at this. I don't know much about Cargo internals, but here's what I've found so far. |
This is because when running cargo check we are emitting metadata files rather than object files and so we use the |
The Regardless, a valid fingerprint is generated for lib targets which prevents it from being re-checked. Perhaps the |
Sure, any help is appreciated, as I'm not familiar with cargo internals either.
The freshness of the lib target? Seems like a decent approach. I'll try that. |
I assume when a user runs if unit.profile.check && unit.pkg.package_id() == cx.ws.current_opt().unwrap().package_id() {
freshness = Freshness::Dirty;
} I haven't thought through what the implications are inside a workspace with multiple packages, and obviously the |
Great! I was about to post that just testing this: @@ -250,6 +251,10 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>,
freshness = Freshness::Dirty;
}
+ if unit.profile.check && unit.target.is_lib() {
+ freshness = Freshness::Dirty;
+ }
+
(dirty, fresh, freshness)
};
jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness)?; was probably not enough, as it recompiled all libraries, not just the crate one. With your suggestion, the warnings are available on subsequent runs. The downside is performance: testing with cargo itself, it takes around 6sec to
Me neither.
I have no idea what a virtual manifest means in this context, but if it has no real library associated, we probably don't need to override the freshness if |
Yea. Someone else opened #2494 as a feature request to cache the messages, but I think that would be a significant project for a limited use case.
I believe in this situation, the top-level manifest in a workspace (using the |
I confirm that |
I think that should be fine. |
`cargo check` for binaries will always emit warnings, even when the files in the project haven't changed. For `cargo check --lib`, warnings were emitted on the first run, but subsequent runs would not trigger a recompilation of the library when no files have changed, hence preventing warnings to appear. This commit forces a recompilation of the library top-level target (*not* library dependencies) when using the `check` command. Closes rust-langGH-3624.
My IDE autoruns I need to alias cargo check and trick its metadata: |
Since the output of |
I'm not sure what the format of an |
Are there any plans to fix this? It's still pretty annoying. |
I get the same behaviour for both cases: the warning is issued the first time, but not repeated the second time. It would be really useful if the warnings were repeated. |
Yep, closing in favor of the tracking issue. |
$ cargo new --bin mybin && cd mybin && sed -i '1ifn foo(){}' src/main.rs && cargo check && cargo check
:$ cargo new --lib mylib && cd mylib && sed -i '1ifn foo(){}' src/lib.rs && cargo check && cargo check
:Which one is the intended behavior for
cargo-check
? I personally believe it is useful to reissue warnings. The user might accidentally close or clear the terminal, and might want to get the warnings back without modifying the code.The text was updated successfully, but these errors were encountered: