Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Filter by machine applicability #97

Merged

Conversation

killercup
Copy link
Member

Finally -- we have a way to indicate that we trust a lint! This is currently an unstable feature in rustc and thus requires nightly.

The first lints that are currently as machine applicable land with rust-lang/rust#50454, so adding tests will have to wait for a bit -- see #95.

(this is currently based on #96)

@killercup killercup force-pushed the feature/filter-by-machine-applicability branch 3 times, most recently from 3ee72ab to 0c11173 Compare May 6, 2018 20:10
@Manishearth
Copy link
Member

With luck rust-lang/rust#50486 can land and we don't have to pass down a -Z flag

@alexcrichton
Copy link
Member

Looks reasonable to me! If possible though I'd prefer to wait for the Rust PR to land so we can avoid using an extra env var in the tests, but is that ok?

@killercup
Copy link
Member Author

@alexcrichton that means we can only use "upgraded" lints in tests. (Which is okay, and probably a good idea in the long run)

@alexcrichton
Copy link
Member

Ah yeah I think that's ok, all the tests currently are "just the first thing that provided a suggestion"

@killercup killercup force-pushed the feature/filter-by-machine-applicability branch from 9a29f57 to 7d5bb22 Compare May 23, 2018 12:18
@killercup
Copy link
Member Author

Alright, the rustc 1.28.0-nightly (71e87be38 2018-05-22) contains the stable applicability field.

I haven't touched the test file content and used the yolo env var to keep the tests working. I expect we can quickly change the tests to use "stable" lints without much code change once rust-lang/rust#50723 lands.

r? @alexcrichton

src/lib.rs Outdated
match (filter, &span.suggestion_applicability) {
(MachineApplicableOnly, Some(MachineApplicable)) => true,
(MachineApplicableOnly, _) => false,
(_, _) => true,
Copy link
Member

Choose a reason for hiding this comment

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

Could the left hand side of this match be Everything to get exhaustive matches to kick in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, good idea

@@ -111,6 +114,7 @@ fn broken_fixes_backed_out() {

// Attempt to fix code, but our shim will always fail the second compile
p.expect_cmd("cargo-fix fix")
.env("__CARGO_FIX_YOLO", "true")
Copy link
Member

Choose a reason for hiding this comment

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

Hm does this mean that the lints we're testing against aren't currently classifed as "machine applicable"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah

Copy link
Member

Choose a reason for hiding this comment

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

Hm ok, could we perhaps start testing lints that are classified as machine applicable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, like I said, we don't have many -- just unreachable_pub, bare_trait_object, and abs_path_with_module. Do you want to rewrite the tests to always use those? I'd wait a bit for more applicability markers to land and then refactor the tests.

Copy link
Member

Choose a reason for hiding this comment

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

Hm ok, the 2018 compatibility lints are at least machine applicable, right? If so can you make sure that they're already tested and/or add a test for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right -- everything but the upgrade_extern_crate case work without the env var. Updated.

Copy link
Member

Choose a reason for hiding this comment

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

Nice!

As one final comment, could this be an extension method for just the test suite to do something like .fix_everything() instead of duplicating the env var? Other than that r=me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea!

@killercup killercup force-pushed the feature/filter-by-machine-applicability branch from 52c9c36 to 2eaaa75 Compare May 23, 2018 14:43
@killercup
Copy link
Member Author

Alright, let's land this! (I'll be afk for a bit but will try to push a new release to crates.io in a bit)

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.

3 participants