Commit graph

21108 commits

Author SHA1 Message Date
Timo
f58088b23e
Add match-based manual try to clippy::question_mark (#13627)
Closes #10.

changelog: [`question_mark`]: Now lints for match-based manual try
2024-11-10 16:26:56 +00:00
Manish Goregaokar
4f0e46b74d
Fix large_include_file lint being triggered all the time by doc comments (#13672)
Fixes #13670.

Bug was that I forgot to add the comparison with the included file
content length...

changelog: Fix `large_include_file` lint being triggered all the time by
doc comments
2024-11-09 16:01:12 +00:00
Guillaume Gomez
223bffd0d2 Fix large_include_file lint being triggered all the time by doc comments 2024-11-09 13:55:20 +01:00
Jason Newcomb
8cfb95959b
fix: identity_op suggestions use correct parenthesis (#13647)
The `identity_op` lint was suggesting code fixes that resulted in
incorrect or broken code, due to missing parenthesis in the fix that
changed the semantics of the code.

For a binary expression, `left op right`, if the `left` was redundant,
it would check if the right side needed parenthesis, but if the `right`
was redundant, it would just assume that the left side did not need
parenthesis.

This can result in rustfix generating broken code and failing, or
generating code that has different behavior than before the fix. e.g.
`-(x + y + 0)` would turn into `-x + y`, changing the behavior, and
`1u64 + (x + y + 0i32) as u64` where `x: i32` and `y: i32` would turn
into `1u64 + x + y as u64`, creating an error where `x` cannot be added
to the other values, as it was never cast to `u64`.

This commit fixes both of these problems by always checking the
non-redundant child of a binary expression for needed parenthesis.

fixes #13470

changelog: [`identity_op`]: Fix suggested code that is broken or has
changed behavior
2024-11-09 05:03:10 +00:00
TheSlapstickDictator
ef0f1cad59 Remove check for duplicate parenthesis
It was an incorrect, and could lead to behavior changes in the
suggested code
2024-11-07 20:45:15 -08:00
Philipp Krones
f712eb5cdc
Merge pull request #13657 from jdonszelmann/disallowed-macros-to-early
collect attribute spans early for disallowed macros
2024-11-07 19:23:20 +00:00
Philipp Krones
3518178443
Merge pull request #13639 from flip1995/rustup
Rustup
2024-11-07 18:02:25 +00:00
Philipp Krones
b1166963aa
Remove CI badge from README and book 2024-11-07 18:57:29 +01:00
Philipp Krones
a28c44fc96
Merge pull request #13587 from Kobzol/ci-remove-bors
Switch CI from bors to merge queue
2024-11-07 17:42:31 +00:00
Jakub Beránek
843ef1b1f0
Remove path filter
It would cause issues with the required jobs, and it is probably useless anyway, the vast majority of PRs seem to change Rust source files.
2024-11-07 18:32:06 +01:00
Jakub Beránek
9ebe68d8c3
Add conclusion job to PR CI 2024-11-07 18:30:28 +01:00
Philipp Krones
d583df02cc
Remove ui/no_lints.rs test
This test was only meant for debugging purposes
2024-11-07 17:27:46 +01:00
Philipp Krones
a5d6100a10
Bump nightly version -> 2024-11-07 2024-11-07 17:27:46 +01:00
Philipp Krones
b27570b19b
Fix cargo dev update_lints
Now that lints can add @eval_always at the end of their definition, the lint
declaration might not end right after the description. The `update_lints`
command can skip everything that comes after that.
2024-11-07 17:27:46 +01:00
Philipp Krones
c64f1e3591
Fix lint_without_lint_pass internal lint 2024-11-07 17:27:46 +01:00
Philipp Krones
4f12b98654
Clean up declare_clippy_lint
The new @eval_always option should always follow after a comma for consistency
with the declare_tool_lint macro.

Rename $catergory->$level.
2024-11-07 17:22:32 +01:00
Philipp Krones
03daf7ccb2
Fix author lint and move it back to tests/ui
The author lint is not an internal lint, and should also be enabled, when Clippy
is distributed through rustup. This moves the author lint test cases back to
tests/ui.
2024-11-07 17:22:32 +01:00
Philipp Krones
b816d4ee4f
Merge remote-tracking branch 'upstream/master' into rustup 2024-11-07 17:22:32 +01:00
bors
ab560d88e9 Auto merge of #13661 - alex-semenyuk:doc_fix, r=Manishearth
Link fix

[`clippy::await_holding_lock`](https://rust-lang.github.io/rust-clippy/master/index.html#/await_holding_lock) has unformatted link

changelog: none
2024-11-06 17:06:44 +00:00
alexey semenyuk
7bcd578a02
Link fix 2024-11-06 18:23:01 +05:00
bors
f02a0208e5 Auto merge of #13659 - samueltardieu:push-twtxmtvopoxo, r=blyxyas
no_mangle_with_rust_abi: properly position the suggested ABI

Fix #13656

changelog: [`no_mangle_with_rust_abi`]: properly position the suggested ABI
2024-11-06 11:27:13 +00:00
Samuel Tardieu
c1ab18d1c0 no_mangle_with_rust_abi: properly position the suggested ABI 2024-11-05 23:10:41 +01:00
Jonathan Dönszelmann
c93109674f
collect attribute spans early for disallowed macros 2024-11-05 20:46:44 +01:00
Matthias Krüger
4847c40c8b Rollup merge of #132637 - blyxyas:lint-less-passes, r=flip1995
Do not filter empty lint passes & re-do CTFE pass

Some structs implement `LintPass` without having a `Lint` associated with them #125116 broke that behaviour by filtering them out. This PR ensures that lintless passes are not filtered out.
2024-11-05 20:10:53 +01:00
bors
6631a2c1b7 Auto merge of #13654 - GnomedDev:early-exit-visitors, r=Alexendoo
Swap Visitors to early exit, instead of storing poison flag

I noticed that a bunch of visitors had a `poison` or `success` field, when they could just be returning `ControlFlow`.

changelog: none
2024-11-05 17:39:32 +00:00
blyxyas
626406f1b3 Do not filter empty passes & Make CTFE Clippy into lintless pass 2024-11-05 15:27:09 +01:00
bors
d8a3fcc792 Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
Remove unnecessary pub enum glob-imports from `rustc_middle::ty`

We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly.

`@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`.

This PR is a bit large, but it's just naming.

The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine.

r? `@noratrieb` or reassign
2024-11-05 08:30:56 +00:00
TheSlapstickDictator
1b7239d954 Fixing a missed check for needs_parenthesis in division 2024-11-04 19:19:58 -08:00
GnomedDev
44c2a82972
Swap Visitors to early exit, instead of storing poison flag 2024-11-04 23:49:25 +00:00
Jonathan Dönszelmann
63d0ba9de9 Move two attribute lints to be early pass (post expansion) 2024-11-04 22:47:22 +01:00
Michael Goulet
efeed550c4 Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
Michael Goulet
b14362f665 ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
bors
ccf7c88386 Auto merge of #13648 - samueltardieu:push-rpxvoukpolvm, r=Centri3
needless_continue: check labels consistency before warning

changelog: [`needless_continue`]: check labels before warning about `continue` as the last statement in a loop body

Fix #13641
2024-11-03 23:17:36 +00:00
bors
a1a9aaef87 Auto merge of #13631 - samueltardieu:push-uoowutzkvsrk, r=Centri3
no_mangle attribute requires unsafe in Rust 2024

Tests without unsafe must not run in edition 2024. Also, error messages have been modified to include the full attribute, so that a use of `#[unsafe(no_mangle)]` does not produce an error message containing `#[no_mangle]`.

changelog: [`no_mangle_attribute`]: handle `#[unsafe(no_mangle)]` as well
2024-11-03 19:43:19 +00:00
Michael Goulet
f0cf9969cb Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
TheSlapstickDictator
6d738f6bc0 Fix parens getting removed for non-associative operators 2024-11-03 09:23:03 -08:00
bors
040129b774 Auto merge of #13629 - samueltardieu:push-nwukowumrvsn, r=flip1995
Return iterator must not capture lifetimes in Rust 2024

In Rust 2024, by default lifetimes will be captured which does not reflect the reality since we return an iterator of `DefId` which do not capture the input parameters.

changelog: none
2024-11-03 15:50:48 +00:00
Samuel Tardieu
2f1b7b64fb needless_continue: check labels consistency before warning 2024-11-03 16:49:15 +01:00
bors
ddd1a86c66 Auto merge of #13573 - y21:issue13427, r=Centri3
Don't lint unnamed consts and nested items within functions in `missing_docs_in_private_items`

With this change we no longer require doc comments for `const _: ()` items as well as nested items in functions or other bodies. In both of those cases, rustdoc generates no documentation even with `--document-private-items`.

Fixes #13427 (first commit)
Fixes #13298 (second commit)
cc https://github.com/rust-lang/rust-clippy/issues/5736#issuecomment-668524296

changelog: [`missing_docs_in_private_items`]: avoid linting in more cases where rustdoc generates no documentation
2024-11-03 09:10:22 +00:00
TheSlapstickDictator
a0b7681a6f fix: identity_op suggestions use correct parenthesis
The `identity_op` lint was suggesting code fixes that resulted
in incorrect or broken code, due to missing parenthesis in the fix
that changed the semantics of the code.

For a binary expression, `left op right`, if the `left` was redundant,
it would check if the right side needed parenthesis, but if the `right`
was redundant, it would just assume that the left side did not need
parenthesis.

This can result in either rustfix generating broken code and failing,
or code that has different behavior than before the fix.
e.g. `-(x + y + 0)` would turn into `-x + y`, changing the behavior,
and `1u64 + (x + y + 0i32) as u64` where `x: i32` and `y: i32` would
turn into `1u64 + x + y as u64`, creating broken code where `x` cannot
be added to the other values, as it was never cast to `u64`.

This commit fixes both of these cases by always checking the
non-redundant child of a binary expression for needed parenthesis, and
makes it so if we need parenthesis, but they already exist, we don't add
any redundant ones.

Fixes #13470
2024-11-02 19:47:11 -07:00
bors
52b8324503 Auto merge of #13585 - GuillaumeGomez:no-js, r=Alexendoo
Improve display of clippy lints page when JS is disabled

There is no point in displaying the settings menu and the filters if JS is disabled. So in this case, this PR simply hides it:

![image](https://github.com/user-attachments/assets/e96039a9-e698-49b7-bf2b-70e78442b305)

For the theme handling though, I need to send a fix to mdBook first. But once done, it'll look as expected (dark if system is in dark mode).

changelog: Improve clippy lints page display when JS is disabled.

r? `@Alexendoo`
2024-11-02 13:49:04 +00:00
GnomedDev
139bb25927 Avoid linting for closures with inferred return types 2024-11-02 13:41:16 +00:00
bors
5c6fe68c00 Auto merge of #13376 - decryphe:source-ordering, r=llogiq
new lint: `source_item_ordering`

changelog: [`source_item_ordering`]: Introduced a new restriction lint that checks the ordering of items in Modules, Enums, Structs, Impls and Traits.

From the written documentation:

> Why restrict this?
> Keeping a consistent ordering throughout the codebase helps with working as a team, and possibly improves maintainability of the codebase. The idea is that by defining a consistent and enforceable rule for how source files are structured, less time will be wasted during reviews on a topic that is (under most circumstances) not relevant to the logic implemented in the code. Sometimes this will be referred to as "bike-shedding".
>
> Keep in mind, that ordering source code alphabetically can lead to reduced performance in cases where the most commonly used enum variant isn't the first entry anymore, and similar optimizations that can reduce branch misses, cache locality and such. Either don't use this lint if that's relevant, or disable the lint in modules or items specifically where it matters. Other solutions can be to use profile guided optimization (PGO), or other advanced optimization methods.

I tried to build it as configurable as possible, as such a highly opinionated lint should be adjustable to personal opinions.

I'm open to any input and will be available both here and on the zulip for communication. In the meantime I'll be testing this lint against my own code-bases, which I've (manually) kept ordered with the default config, to see how well it works in practice.

And lastly, a big thanks to the community for making clippy the best linter there is!
2024-11-02 11:03:30 +00:00
bors
e8b78e2f66 Auto merge of #13630 - samueltardieu:push-qrnxuykslnsl, r=y21
Use match ergonomics compatible with editions 2021 and 2024

This PR contains the minimal changes needed to make Clippy match ergonomics work with both Rust 2021 and Rust 2024.

changelog: none
2024-11-01 20:23:33 +00:00
bors
9d03956fad Auto merge of #13635 - Alexendoo:cargo-dev-serve-watch-test, r=blyxyas
Watch `tests/compile-test.rs` in `cargo dev serve`

Changes to `compile-test.rs` will also need a rerun of `collect-metadata`

changelog: none
2024-11-01 19:45:24 +00:00
GnomedDev
6205bcf0f1
Add match-based manual try to clippy::question_mark 2024-11-01 19:42:54 +00:00
bors
e4dc892ae3 Auto merge of #13608 - J-ZhengLi:issue12338-new, r=Alexendoo
[`infinite_loops`]: fix incorrect suggestions on async functions/closures

closes: #12338

I intend to fix this in #12421 but got distracted by some other problems in the same lint, delaying the process of closing the actual issue. So here's a separated PR that only focus on the issue and nothing else.

---

changelog: [`infinite_loops`]: fix suggestion error on async functions/closures
2024-11-01 19:36:02 +00:00
Guillaume Gomez
ac764df8ab Handle noscript style with "js" class on <html>. 2024-11-01 20:20:12 +01:00
Guillaume Gomez
ca5c6f6c26 Improve theme handling when JS is disabled 2024-11-01 20:20:12 +01:00
Guillaume Gomez
c056928af2 Improve display of clippy lints page when JS is disabled 2024-11-01 20:20:12 +01:00