Two optimizations have been done when checking for the context in which
to apply the lint:
- Checking for the mere presence of comments does not require building a
`String` with the comment to then check if it is empty and discard it.
- Checking for the presence of comment can be done after we have checked
that we do have a `if` construct that we intend to lint instead of for
every expression.
changelog: none
r? blyxyas
Two optimizations have been done when checking for the context in which
to apply the lint:
- Checking for the mere presence of comments does not require building a
`String` with the comment to then check if it is empty and discard it.
- Checking for the presence of comment can be done after we have checked
that we do have a `if` construct that we intend to lint instead of for
every expression.
This limits repeated lookups in pre-checks (to determine if a MSRV
should be checked), especially when those require locking up an
interner:
- The `core` crate is looked up once when creating the lint, instead of
comparing the crate name with `sym::core` at every check.
- `span.ctxt().outer_expn_data()` is lookup up only once.
changelog: none
r? blyxyas
Follow-up of https://github.com/rust-lang/rust-clippy/pull/15208.
This PR removes the CSS `bootstrap` dependency which contains 1504 CSS
rules and weights 16.1 kB minified. Considering we used less than 50 of
these rules, it's quite a waste.
So this time, there are minor UI changes:
* The "expand/collapse all" buttons icon changed. It now uses the one
from font-awesome. It's quite close but not exactly the same.
* The layout is slightly different (you need to switch between two tabs
to actually see the difference).
Before this PR:
<img width="719" height="515" alt="image"
src="https://github.com/user-attachments/assets/1f067046-4ee9-49ee-bf38-50a8bf9888f2"
/>
With this PR:
<img width="719" height="515" alt="image"
src="https://github.com/user-attachments/assets/80331c98-1a1e-418f-b481-5b3f5c276926"
/>
With this, we will be able to go even further on reducing the page size
next. =D
This time, the DOM size itself reduced a bit but the difference is too
small to be noteworthy.
r? @samueltardieu
changelog: Remove CSS bootstrap dependency
This limits repeated lookups in pre-checks (to determine if a MSRV
should be checked), especially when those require locking up
an interner:
- The `core` crate is looked up once when creating the lint, instead of
comparing the crate name with `sym::core` at every check.
- `span.ctxt().outer_expn_data()` is lookup up only once.
changelog: [`collapsible_else_if`]: fix suggestion when inner `if` as
wrapped in parentheses
changelog: [`collapsible_if`]: fix suggestion when inner `if` as wrapped
in parentheses
fixes https://github.com/rust-lang/rust-clippy/issues/15303
I'm sure this is a bit dirty, but don't currently see a better way.
When I first tried contributing to clippy,
I encountered the problem that a lot of lint suggestions overlapped with
existing lints, so I would spend a bunch of time implementing something
only to figure out it wasn't actually needed.
The "comparison with existing lints" field should hopefully reduce this
somewhat, while not incresing the burden of
requesting a new lint too much due to not being mandatory.
changelog: none
The `unnecessary_sort_by` lint displays different method names in
message and suggestion, which is a bit confusing.
Also got a question about `UNNECESSARY_SORT_BY` lint definition. Should
we extend its message to also cover *_unstable_* methods?
changelog: [`unnecessary-sort-by`]: sort method consistency in message
and suggestion
Spotted while reading through the new lints in the changelog for Clippy
1.89:
```
1 | error: infallible TryFrom impl; consider implementing From, instead
| ^ this comma looks out of place
```
---
changelog: [`infallible_try_from`]: Fix a typo in the lint message
Violets are red,
Roses are blue,
As August winds whisper,
Take a chance, then rest too.
<hr>
Appreciate it as always @xFrednet
<img width="601" height="744" alt="image"
src="https://github.com/user-attachments/assets/a0e4af41-da97-4565-881b-549ed51d7fc5"
/>
<hr>
Cats for the next release can be traditionally nominated in the comments
:D
Please be more active and cat-minded 😻
changelog: none
r? flip1995
match on `StmtKind` directly
use a let-chain
break up match for a nicer let-chain
shorten `get_line`
move `expr` check down in the inside case as well
for consistency
use `shrink_to_hi`
Apply suggestion
Co-authored-by: Samuel Tardieu <sam@rfc1149.net>
Apparently, one can surround a pattern with an arbitrary number of
parens, and the resulting `Pat` won't include the span of those parens.
And the previous approach extended the to-be-deleted span all the way to
the end of `Pat`'s span, so it included the closing paren.
I think the new approach is more robust anyway, since all we care to
remove (besides the `_`) is the `:`, so we search just for that.
~This does leave one extra whitespace in one of the test cases, but I'd
say let rustfmt handle that.~ fixed in the third commit
changelog: [`let_with_type_underscore`]: don't eat closing paren in `let
(i): _ = 0;`
fixes https://github.com/rust-lang/rust-clippy/issues/15377
We were calling an expensive functions lots of times resulting in 12
million instructions for `broken_links`, the doc lint optimization is
not over yet...
Now the instruction count for `broken_links` is at a healthy 27
thousand. This improvement is a difference of 1.5% in the total analysis
time for `tokio`.
changelog:[`broken_links`]: Optimize by 99.77%
Now that `if let` chains have been introduced, the `if_chain` external
crate is no longer necessary. Dropping special support for it also
alleviates the need to keep the crate as a dependency in tests.
This is a cleanup PR.
changelog: none
base check
same fields different struct
reordered fields
different paths to the same struct
same for tuple structs
style: use `zip`-the-function all over the place
makes the code a bit more concise by removing the need for explicit
`.iter()`
style: move precondition checking to the match guard
the match arms above put the "sanity" checks in the guard, and call only
`check_pat` in the body. With this commit, the (tuple) struct cases
follow that convention as well. Well, almost -- I think the ident check
belongs to the second category of checks, so I put it in the body as
well
misc: use `None` in the pattern directly
this'll probably be marginally faster thanks to the equality check being
now structural
move the tests to the right file
When an expression is made of a `!` or `-` unary operator which does not
change the type of the expression, use a new variant in `Sugg` to denote
it. This allows replacing an extra application of the same operator by
the removal of the original operator instead.
Some suggestions will now be shown as `x` instead of `!!x`. Right now,
no suggestion seems to produce `--x`.
changelog: none