Skip to content

Integrate rustfix into clippy test suite #2376

Closed
@killercup

Description

@killercup

Let's test the suggestions clippy generates! (I talked about this with various people from time to time, but never opened an issue here for discussion.)

Recently, I refactored rustfix' test suite to basically not test the rustfix CLI but the suggestions and their fixes. You can find the test code here. It's pretty self-contained and only uses rustfix to get the suggestion from the compiler (but contains code to apply them). Indeed, the rustfix code base is very small and basically only a shim around parsing the compiler's json output and extracting suggestions. So in theory, I could easily make this a single test file (i.e., without dependencies on the rustfix repo) that you add as a job to clippy's CI.

The same test procedure would work very well with clippy's UI tests: If there is a foo.fixed.rs next to foo.rs, the test will apply rustfix to foo.rs and assert that it generates foo.fixed.rs (and that foo.fixed.rs compiles!). This would be a great way to ensure that clippy generates sensible suggestions, document edge cases, and also be a good starting point to specify which suggestions are auto-applicable (cf. https://github.com/killercup/rustfix/pull/44#issuecomment-357920563, rust-lang/rust#39254).

Metadata

Metadata

Assignees

Labels

C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.L-suggestionLint: Improving, adding or fixing lint suggestions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions