Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Detect clippy diagnostic source #705

Merged
merged 1 commit into from
Feb 11, 2018
Merged

Conversation

alexheretic
Copy link
Member

Adds source clippy, rather than rustc, when compiler messages include "rust-clippy" (the project name part of the clippy more info links).

While this method is fairly crude the chance of labelling an actual rustc error as clippy seems very low. As such this is definitely an improvement to what we have with little downside. Also since there isn't much code to it we can switch to a better source-detection method easily when one appears.

I've reworked the diagnostic message tests a little to aid source testing along with the new clippy diagnostic formatting regression test.

@@ -224,14 +225,20 @@ fn parse_diagnostics(message: &str) -> Option<FileDiagnostic> {
primary_message.push_str(&format!("\n\n{}", notes));
}

// A diagnostic source is quite likely to be clippy if it contains
// the further information link to the rust-clippy project.
if primary_message.contains("rust-clippy") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: I think it'd be simpler if we would completely define it in one place like let source = if ... { "clippy" } else { "rustc" };

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the detection logic is in the main diagnostic building scope, yet applied to all secondary diagnostics too I think this is a fairly graceful way. That you could return the main diagnostic plus the source in a tuple and avoid the mut, and while I generally agree with avoiding mut I don't think there's much of a win here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you’re right - I got confused by partially unfolded code in between, my bad!

@Xanewok
Copy link
Member

Xanewok commented Feb 10, 2018

Oh, I'm sorry - it seems #681 made this unmergeable. Would you be so kind and rebase this?

Update clippy to 0.0.186
@Xanewok Xanewok merged commit 52f5348 into rust-lang:master Feb 11, 2018
@Xanewok
Copy link
Member

Xanewok commented Feb 11, 2018

Thanks!

@Xanewok Xanewok mentioned this pull request Feb 11, 2018
@alexheretic alexheretic deleted the clippy-source branch February 11, 2018 20:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants