| Age | Commit message (Collapse) | Author | Lines |
|
|
|
r? @ghost
changelog: none
|
|
|
|
|
|
|
|
fixes #13934
I modified the part for checking if the map is used so that it can check
field and index exprs.
changelog: [`map_entry`]: fix FP on struct member
|
|
In the case where `iter` is a `DoubleEndedIterator`, replacing a call to
`iter.last()` (which consumes `iter`) by `iter.next_back()` (which
requires a mutable reference to `iter`) cannot be done when `iter` is a
non-mutable binding which is not a mutable reference. When possible, a
local immutable binding is made into a mutable one.
Also, the applicability is switched to `MaybeIncorrect` and a note is
added to the output when the element types have a significant drop,
because the drop order will potentially be modified because
`.next_back()` does not consume the iterator nor the elements before the
last one.
Fix #14139
changelog: [`double_ended_iterator_last`]: do not trigger on
non-reference immutable receiver, and warn about possible drop order
change
|
|
`iter.last()` will drop all elements of `iter` in order, while
`iter.next_back()` will drop the non-last elements of `iter` when
`iter` goes out of scope since `.next_back()` does not consume its
argument.
When the transformation proposed by `double_ended_iterator_last` would
concern an iterator whose element type has a significant drop, a note is
added to warn about the possible drop order change, and the suggestion
is switched from `MachineApplicable` to `MaybeIncorrect`.
|
|
|
|
In the case where `iter` is a `DoubleEndedIterator`, replacing a call to
`iter.last()` (which consumes `iter`) by `iter.next_back()` (which
requires a mutable reference to `iter`) cannot be done when `iter`
Is not a mutable binding or a mutable reference.
When `iter` is a local binding, it can be made mutable by fixing its
definition site.
|
|
fixes #14148
Another case of #13077 and #8646
changelog: [`needless_option_as_deref`]: fix FP in trait
|
|
If the part being replaced is an `if` expression following an `else`,
the replacement expression must be blockified.
|
|
The end goal is to eliminate `Map` altogether.
I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
|
|
Cleans up some changes from
https://github.com/rust-lang/rust-clippy/pull/11421
I searched for any `.stderr` files where the number of errors changed
and reverted + manually added the annotations for them
Also fixes `tests/ui/asm_syntax_not_x86.rs`
r? @flip1995
changelog: none
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adding annotations, it doesn't work anymore
|
|
|
|
Fixed #14156
changelog: none
|
|
implement `Copy` (#14207)
Fix #14201
changelog: [`unnecessary_map_or`]: do not consume the comparison value
if it does not implement `Copy`
|
|
This is the lint described at
https://github.com/rust-lang/rust/pull/136308#issuecomment-2625485331
that recommends using HTML to nest links inside code.
changelog: [`doc_link_code`]: warn when a link with code and a code span
are back-to-back
|
|
|
|
(#13953)
Fixes #13885.
Fixes https://github.com/rust-lang/rust-clippy/issues/14007.
Problem was that I forgot to check whether or not the `span` was a
"real" one. Because if not, then it starts pointing to pretty much only
wrong content, hence the problems we saw with clippy linting on
`clippy.toml`.
changelog: Fix `literal_string_with_formatting_args` lint emitted when
it should not
r? @samueltardieu
|
|
|
|
|
|
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
Close #14195
changelog: [`mem_replace_option_with_some`]: new lint
|
|
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
|
|
|
|
Checks for `Read::bytes()` on an unbuffered Read type.
The default implementation calls `read` for each byte, which can be very
inefficient for data that’s not in memory, such as `File`.
Considerations which I'd like to have feedback on:
* Currently this lint triggers when `.bytes()` is called on any type
that implements `std::io::Read` but not `std::io::BufRead`. This is
quite aggressive and in and may result in false positives. Alternatives:
* Only trigger on concrete types, not generic types. This does mean that
cases where a function is generic over a `R: Read` and calls `.bytes()`
are not caught by the lint, which could be quite a nasty case of this
bug.
* Only trigger on an allowlist of stdlib types
* Compromise: Is it possible to make this lint `pedantic` on types that
are not on a allowlist?
* Theoretically, a trait implementation of `Read` could override
`.bytes()` with an efficient implementation. I'm not sure how to add
this check to the lint, and I can't find any cases of this being done in
practice.
* I don't think an automatic fix for this lint is possible, but I'd love
to be proven wrong
* This is my first time contributing to clippy, please let me know if I
did anything wrong
Fixes #14087
```
changelog: [`unbuffered_bytes`]: new lint
```
|
|
fix #14192
changelog: [`manual_slice_fill`]: resolve FP caused by missing index
checks for the slice
|
|
|
|
By default, do not lint `.unwrap()` and `.expect(…)` in always const
contexts, as a failure would be detected at compile time anyway.
New options `allow_expect_in_consts` and `allow_unwrap_in_consts`,
defaulting to `true`, can be turned unset to still lint in always const
contexts.
|
|
(#14168)
Fixes #12302
changelog: [`just_underscores_and_digits`]: fix false positive in error
recovery scenario
|
|
Empty idents come from error recovery, and should imply that a
better error has already been emitted.
|
|
`<T as Trait>::AssocT` projections (#14125)
changelog: [`declare_interior_mutable_const`,
`borrow_interior_mutable_const`]: resolve `<T as Trait>::AssocT`
projections
---
This came up during https://github.com/rust-lang/rust/pull/130543 where
we have `<T as AtomicPrimitive>::Assoc = AtomicT` instead of just
`AtomicT` and clippy failed to resolve that properly.
This really needs a review, because
- I don't know if `try_normalize_erasing_regions` is the right thing to
call here.
- I'm not sure if I peel off the correct amount of `ValTree::Branch`
layers (I think I do).
Also, shouldn't this lint's infrastructure rely on `Freeze` trait
(https://github.com/rust-lang/rust/issues/121675) instead of hardcoding
a list of known-to-be-interior-mutable types?
---
Previously filed this in the main rust repo
(https://github.com/rust-lang/rust/pull/136369), was asked to do it here
instead
(https://github.com/rust-lang/rust/pull/136369#issuecomment-2628527774).
|
|
|
|
When looking for `Default` impls that could be derived, we look at the
body of their `fn default()` and if it is an fn call or literal we check
if they are equivalent to what `#[derive(Default)]` would have used.
Now, when checking those fn calls in the `fn default()` body, we also
compare against the corresponding type's `Default::default` body to see
if our call is equivalent to that one.
For example, given
```rust
struct S;
impl S {
fn new() -> S { S }
}
impl Default for S {
fn default() -> S { S::new() }
}
```
`<S as Default>::default()` and `S::new()` are considered equivalent.
Given that, if the user also writes
```rust
struct R {
s: S,
}
impl Default for R {
fn default() -> R {
R { s: S::new() }
}
}
```
the `derivable_impls` lint will now trigger.
|
|
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> $DIR/attempted-access-non-fatal.rs:7:15
|
LL | let _ = 2.l;
| ^
|
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
|
LL - let _ = 2.l;
LL + let _ = 2.0f64;
|
```
|
|
Since comparisons on types not implementing `Ord` (such as `f32`) are
not inverted, they must be enclosed in parentheses when they are
negated.
|
|
editions (#14180)
The first commit fixes #14164 by making sure that temporaries with
non-static references are also looked for in expressions coming from
expansion. The shortcut that was done skipped those parts and reported
an absence of short-lived temporaries, which was incorrect.
The second commit distinguishes between edition 2024 and earlier ones.
Starting from edition 2024, the problematic drop order has been fixed,
and block variables, which might be referenced in a block expression,
are freed after the block expression itself. This allows more
`let_and_return` cases to be reported starting with edition 2024,
whereas in earlier editions an intermediary variable was necessary to
reorder the drops.
Incidentally, since Clippy is compiled in edition 2024 mode, the second
commit has led to a fix in
`clippy_lints/src/matches/significant_drop_in_scrutinee.rs`.
changelog: [`let_and_return`]: lint more cases in edition 2024, and fix
a false positive involving short-lived block temporary variables in
earlier editions.
|