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

Duplicated warnings in JetBrains editors #10904

Closed
rsalmei opened this issue Jul 26, 2022 · 1 comment
Closed

Duplicated warnings in JetBrains editors #10904

rsalmei opened this issue Jul 26, 2022 · 1 comment
Labels
C-bug Category: bug

Comments

@rsalmei
Copy link

rsalmei commented Jul 26, 2022

Problem

Hi, I think I've found one case where warnings are still duplicated, or perhaps is a regression.
I'm using 1.62.1, and I see them doubled on Pycharm (up to date, with Rust plugin up to date).
To simulate, just create a new binary project, and insert any use:

use std::sync::Arc;

fn main() {
    println!("Hello, world!");
}

Then, create a quick Run Configuration with cargo check --all-targets:
image

Note the "1 warning" on the left, but doubled on the complete output.
Also note that Pycharm uses JSON: cargo check --color=always --message-format=json-diagnostic-rendered-ansi --all-targets
On the terminal, I can reproduce with the exact same command, but not with either cargo check --color=always --message-format=json-diagnostic-rendered-ansi or cargo check --color=always --all-targets, hence I think the problem is on the interaction between these two options.

Thanks!

Steps

  1. create a new bin project
  2. insert any use
  3. in Run -> Edit Configurations, add a cargo one with command: check --all-targets and your current workdir
  4. run it (^R on macOS)

Possible Solution(s)

No response

Notes

No response

Version

No response

@rsalmei rsalmei added the C-bug Category: bug label Jul 26, 2022
@weihanglo
Copy link
Member

Thanks for your step-by-step report!

There are two rustc invocations in your reproducible example (a test target and a bin target. check them with --verbose flag on). Both of them emit the same "unused import" diagnostics.

The deduplication behaviour was introduced since 1.55 by #9675. Cargo deduplicates rustc diagnostics message with a rudimental hash-them-all approach. For formats not primary for human to consume, such as json and json-diagnostic-rendered-ansi, Cargo would leave them as-is in order to open a door for downstream tools to program. We might consider introducing a new flag --dedup-message or so to explicitly deduplicate all kinds of messages, though I tend to avoid adding a bunch of flags onto Cargo's already complex surface. IMHO the current status is a good balance between human-readability and extensibility.

I am going to close this. If anyone gets a different thought, please leave comment below and we can revisit it. Thank you!

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants