Fixesrust-lang/rust-clippy#14750 by reducing the lint span for
needless_return.
changelog: [`needless_return`]: Lint span no longer wraps to previous
line
If a type is incomplete, for example if generic parameters are not
available yet, although they are not escaping, its layout may not be
computable. Calling `TyCtxt::layout_of()` would create a delayed bug in
the compiler.
changelog: [`zero_sized_map_values`]: fix ICE
Fixesrust-lang/rust-clippy#14822
r? @Jarcho
If a type is incomplete, for example if generic parameters are not
available yet, although they are not escaping, its layout may not
be computable. Calling `TyCtxt::layout_of()` would create a delayed bug
in the compiler.
A `return` in an expression makes it divergent and cannot be removed
blindly. While this stripping might have been introduced as a way to
catch more cases, it was improperly used, and no tests exhibit a failure
when this special handling is removed.
changelog: [`needless_match`]: do not strip `return` as it might make
the `if let` or `match` divergent in some cases
Fixesrust-lang/rust-clippy#14754
This patch series makes heavy use of interned symbols when matching
against known method names:
- the first commit reorders the current list of symbols in
`clippy_utils::sym`
- the second commit adds symbol reordering and order checking to `clippy
dev fmt` / `clippy dev fmt --check`
- the third commit converts many uses of string matching during linting
to symbols matching
The symbols are kept as-is (not rendered as strings) as much as possible
to avoid needing locking the interner as much as possible. Static
strings have been kept when they are only used when emitting a
diagnostic, as there is no benefit in using interned strings for
de-interning them right after.
changelog: none
r? @Alexendoo
Items such as the `declare_tool_lint!()` macro are publicly reexported
from `rustc_lint_defs` to `rustc_session`. Use the latter for
consistency.
changelog: none
Fixes#13793.
Interestingly enough, to actually check that the macro call has at least
two arguments, we need to use the rust lexer after getting the original
source code snippet.
changelog: Add new `useless_concat` lint
It is not enough to check if an expression type implements `Drop` to
determine whether it can have a significant side-effect.
Also, add tests for unchecked cases which were explicitly handled in the
code, such as checking for side effect in a `struct`'s fields, or in its
base expression.
Fixrust-lang/rust-clippy#14592
changelog: [`no_effect_underscore_binding`]: do not propose to remove
the assignment of an object if dropping it might indirectly have a
visible side effect
Do not attempt to fetch a snippet from expansion. Without this change,
the inside of macros could[*] be shown as the source of the problem.
[*] Due to the way the source code is processed and reparsed in this
macro, the declarative macro has to be located outside the current
source file for the bug to appear. Otherwise, the macro call itself will
be (mis)identified as a potential `struct` field definition and the lint
will not trigger.
changelog: [`empty_struct_with_brackets`]: do not lint code coming from
macro expansion
A representation attribute `#[repr(…)]` might indicate that the ordering
of the fields or the variants is dictated by the API the code is
interfacing with. Better not lint with `arbitrary_source_item_ordering`
in this case.
changelog: [`arbitrary_source_item_ordering`]: do not lint inside items
with `#[repr]` attribute
fixes#12979fixes#12951fixes#13233
Tests still need to be finished and the docs still need to be updated,
but this should otherwise ready.
changelog: Lint `declare_interior_mutable_const` and
`borrow_interior_mutable_const` more precisely
Was disabled in rust-lang/rust-clippy#10855 due to a broken suggestion.
This will only lint if a type is not proveded (e.g. `T::deref`).
changelog: none
Using the function declaration, by stripping the body, is enough to
convey the lint message.
changelog: [`unnecessary_wraps`]: do not include the whole body in the
lint span
Closesrust-lang/rust-clippy#14773
* rename test files inside directories and ui-toml tests
* rename tests prefixed with the lint's name
* better module path renaming when renaming the lint's module
* partially delete lint files when uplifting
* rename ui_test error markers
Clippy should not lint 2 blocks expression for comparison_chain.
Fixesrust-lang/rust-clippy#4725
changelog: [`comparison_chain`]: do not lint 2 blocks expression