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

Disable empty_enum lint on stable (or change recommendation) #6422

Closed
jhpratt opened this issue Dec 4, 2020 · 4 comments
Closed

Disable empty_enum lint on stable (or change recommendation) #6422

jhpratt opened this issue Dec 4, 2020 · 4 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@jhpratt
Copy link
Member

jhpratt commented Dec 4, 2020

Currently the empty_enum lint recommends using the seemingly forever-unstable never type. While the never type may have better compiler support in some aspects, the suggested change to use a wrapper type around ! obviously isn't possible on stable.

I'm not sure whether clippy currently has the ability to have nightly-only lints, but it's what makes sense here imo.

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Dec 5, 2020
@nahuakang
Copy link
Contributor

Has anyone worked on this? If not, I'd be happy to jump on it. @flip1995 Might need a few hints :)

@flip1995
Copy link
Member

@nahuakang You can check with

if !cx.sess.features_untracked().or_patterns {
// Do not suggest nesting the patterns if the feature `or_patterns` is not enabled.
return;
}

if a specific feature is enabled. This lint should only trigger if the never_type feature is enabled.

bors added a commit that referenced this issue Jan 5, 2021
…p1995

Fix: Empty enum never type suggested only if the feature is enabled

This PR addresses [Issue 6422](#6422). Instead of always recommending `never type` for empty enums, Clippy would only recommend [the lint](https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum) if [LatePass.TyCtxt](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) has `features().never_type` enabled.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog:
bors added a commit that referenced this issue Jan 5, 2021
…p1995

Fix: Empty enum never type suggested only if the feature is enabled

This PR addresses [Issue 6422](#6422). Instead of always recommending `never type` for empty enums, Clippy would only recommend [the lint](https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum) if [LatePass.TyCtxt](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) has `features().never_type` enabled.

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`
---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Only trigger [`empty_enum`] lint if `never_type` feature is enabled.
@xFrednet
Copy link
Member

xFrednet commented Feb 4, 2021

Hey, what is the status on this issue? It seems like #6513 implemented this. Can this one be closed or is there still something left to do? 🙃

@nahuakang
Copy link
Contributor

Hey Fred! @flip1995 can correct me if wrong, but I think the issue is fixed now :)

@flip1995 flip1995 closed this as completed Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

No branches or pull requests

4 participants