ast/hir: Rename field-related structures
I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.
- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")
Various visiting and other methods working with the fields are renamed correspondingly too.
The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
Don't lint on `Result` and `Option` types.
Considers `or` patterns.
Considers variants prefixed with `Self`
Suggestions will try to find a common prefix rather than just using the full path
Don't re-export `clippy_utils::*`
changelog: none
This should wrap up the utils-related really big changes. I personally don't see any more sub-modules to be added to `clippy_utils`.
Write literal suggestion
fixes: #6768
changelog: Add suggestion to `write_literal` and `print_literal` lints
changelog: Change `use_debug` to point only at the format string
docs: update RA setup documentation
Add documentation how to get rust-analyzer to like clippys `extern crate` rustc deps.
Fixes#6883
This initially removed `cargo-dev ra_setup` but it is still needed by folks who use intellij rust, so keeping that.
changelog: none
More precise spans for HIR paths
`Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path.
This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span.
This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans).
r? ````@estebank````
2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled
This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments
To do so, we
- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code
Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")
Also rename visiting and other methods working on them.
Do not show docs link when lint doesn't start with "clippy::"
This small change ensures that if the diagnostic functions are called from outside of Clippy, a docs link is not displayed.
---
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: restrict docs links
Refactor unit types
Ref: #6724
r? `@flip1995`
Changes:
1. Extract `unit_types` from `types` group.
2. Move lints of `unit_types` to their own modules.
Notes:
Other lints of `unit_types` is still scattered around the `clippy_lints`, e.g. `result_unit_err` or `option_map_unit_fn`.
These should be addressed in another PR.
changelog: none