Skip to content

Add an option to disable diagnostics #5682

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

Merged
merged 12 commits into from
Aug 18, 2020

Conversation

popzxc
Copy link
Contributor

@popzxc popzxc commented Aug 7, 2020

As far as I know, currently it's not possible to disable a selected type of diagnostics provided by rust-analyzer.

This causes an inconvenient situation with a false-positive warnings: you either have to disable all the diagnostics, or you have to ignore these warnings.

There are some open issues related to this problem, e.g.: #5412, #5502

This PR attempts to make it possible to selectively disable some diagnostics on per-project basis.

@popzxc popzxc changed the title Add a possibility to disable diagnostics Add an option to disable diagnostics Aug 7, 2020
Copy link
Contributor

@jonas-schievink jonas-schievink left a comment

Choose a reason for hiding this comment

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

Is there a way to configure this in VS Code with this PR?

@popzxc
Copy link
Contributor Author

popzxc commented Aug 12, 2020

@jonas-schievink

Is there a way to configure this in VS Code with this PR?

I don't think so. I initially thought that it will be two different features, and thus have to be implemented separately. If you'll give me a clue where the extension provides a configuration for a server, I can implement it (either as a part of this PR, or as a different PR).

@jonas-schievink
Copy link
Contributor

You need to add the new setting to editors/code/package.json, and that should be it

@popzxc popzxc requested a review from jonas-schievink August 14, 2020 04:38
@popzxc
Copy link
Contributor Author

popzxc commented Aug 18, 2020

@jonas-schievink Is there anything else that has to be done within this PR?

#[derive(Debug, Default, Clone)]
pub struct AnalysisConfig {
pub disabled_diagnostics: HashSet<String>,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@matklad is it okay to make this config structure part of AnalysisHost or should it be handled differently?

Copy link
Member

Choose a reason for hiding this comment

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

Good question! Given that we only do surface filtering at the moment, I think it's better to just pass it in as an argument to Analysis::diagnostics.

If, in the future, we decide to disable diagnostics on a more fundamental level (ie, avoid computing them at all), I think we'll have to make this an input of the database.

But for now, adding an argument seems like a better approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@matklad
Copy link
Member

matklad commented Aug 18, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 18, 2020

@bors bors bot merged commit b8dfc33 into rust-lang:master Aug 18, 2020
@popzxc popzxc deleted the add-disable-diagnostics branch August 18, 2020 12:18
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

Successfully merging this pull request may close these issues.

4 participants