-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lints
Description
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" },
]xFrednet, tthebst and antoyo
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints