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

Add disallowed_fields lint #9278

Open
i509VCB opened this issue Aug 1, 2022 · 0 comments
Open

Add disallowed_fields lint #9278

i509VCB opened this issue Aug 1, 2022 · 0 comments
Labels
A-lint Area: New lints

Comments

@i509VCB
Copy link
Contributor

i509VCB commented Aug 1, 2022

What it does

Like disallowed_methods and disallowed_types, this lint warns when a field on a type is used.

Lint Name

disallowed_fields

Category

style

Advantage

  • Using some field on some type may be discouraged in some library.
    • For example, the ABI of some type in a library you depend on may make hiding a field impossible but using said field should be discouraged by code inside your implementation. The lint would allow a more obvious warning.

Drawbacks

  • Might be a niche lint.

Example

Could use a better type as an example:

# clippy.toml
disallowed-fields = [
    # Can use a string as the path of the disallowed field.
    "std::ops::Range::start",
    # Can also use an inline table with a `path` key.
    { path = "std::ops::Range::start" },
    # When using an inline table, can add a `reason` for why the field
    # is disallowed.
    { path = "std::ops::Range::start", reason = "The start of the range is not used" },
]
@i509VCB i509VCB added the A-lint Area: New lints label Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

1 participant