-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clippy subtree update #138761
Clippy subtree update #138761
Conversation
It can make sense to `collect()` an iterator and then immediately iterate over it if the iterator has special methods that you need. For example, the Map iterator doesn't implement Clone, but the collection iterator might. Or the collection iterator might support slicing.
The `comparison_chain` lint might suggest code which seems less natural to beginners. [Discussion](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/demote.20some.20lints.20to.20.60pedantic.60)
`AssocOp::AssignOp` contains a `BinOpToken`. `ExprKind::AssignOp` contains a `BinOpKind`. Given that `AssocOp` is basically a cut-down version of `ExprKind`, it makes sense to make `AssocOp` more like `ExprKind`. Especially given that `AssocOp` and `BinOpKind` use semantic operation names (e.g. `Mul`, `Div`), but `BinOpToken` uses syntactic names (e.g. `Star`, `Slash`). This results in more concise code, and removes the need for various conversions. (Note that the removed functions `hirbinop2assignop` and `astbinop2assignop` are semantically identical, because `hir::BinOp` is just a synonum for `ast::BinOp`!) The only downside to this is that it allows the possibility of some nonsensical combinations, such as `AssocOp::AssignOp(BinOpKind::Lt)`. But `ExprKind::AssignOp` already has that problem. The problem can be fixed for both types in the future with some effort, by introducing an `AssignOpKind` type.
It mirrors `ExprKind::Binary`, and contains a `BinOpKind`. This makes `AssocOp` more like `ExprKind`. Note that the variants removed from `AssocOp` are all named differently to `BinOpToken`, e.g. `Multiply` instead of `Mul`, so that's an inconsistency removed. The commit adds `precedence` and `fixity` methods to `BinOpKind`, and calls them from the corresponding methods in `AssocOp`. This avoids the need to create an `AssocOp` from a `BinOpKind` in a bunch of places, and `AssocOp::from_ast_binop` is removed. `AssocOp::to_ast_binop` is also no longer needed. Overall things are shorter and nicer.
It makes `AssocOp` more similar to `ExprKind` and makes things a little simpler. And the semantic names make more sense here than the syntactic names.
To match `ExprKind::Cast`, and because a semantic name makes more sense here than a syntactic name.
The `has_eligible_receiver()` function had been adapted *a minima* when the `sym::ControlFlow` diagnostic item has been added to rustc. This refactors the function content to make its meaning clearer.
- Remove the `Option` from the result type, as `None` is never returned. - Document the difference from the `BindingMode` in `PatKind::Binding`.
…r=oli-obk Clean up TypeckResults::extract_binding_mode - Remove the `Option` from the result type, as `None` is never returned. - Document the difference from the `BindingMode` in `PatKind::Binding`.
The lint for function calls was previously restricted to functions taking exactly one argument. This was not documented. Generalizing the lint to an arbitrary number of arguments in the function call requires special casing some macro expansions from the standard library. Macros such as `panic!()` or `assert_eq!()` exist since Rust 1.0.0, but modern stdlib expand those macros into calls to functions introduced in later Rust versions. While it is desirable to lint code inside macros, using MSRV-incompatible functions coming from `core` in macro expansions has been special-cased to not trigger this lint. Also, code coming from compiler desugaring may contain function calls (for example, `a..=b` is now desugared into `RangeInclusive::new(a, b)`. Those should not be linted either as the compiler is allowed to use unstable function calls.
This test only makes sense to run in the Clippy repo In the Rust repo the name of the host_compiler is dev, not nightly
Side-effect free expressions are eligible to these lints, whereas previously only local variables were checked.
…#14310) changelog: [`implicit_saturating_sub`, `inverted_saturating_sub`]: extend lints from local variables to side-effect free expressions Noticed when rust-lang#14308 introduced an implicit `saturating_sub` operation and didn't get tagged.
Using `#[allow]` will also apply to child HIR nodes, while `#[expect]` will ensure that the proper HIR node has been used for positioning the lint.
Using `#[allow]` will also apply to child HIR nodes, while `#[expect]` will ensure that the proper HIR node has been used for positioning the lint. changelog: none
fix typo change replacement character in example, remove extraneous space from suggested change add additional testcases; check doc comment not from expansion do not lint on macros, add more testcases fix wording, remove commented out code, add additonal testcase uibless fix doc comments, use optional snippets Remove unneeded additional space
remove additional lint call fix fix lint defs
I love this project but I (again) don't have the time nor energy at the moment. Will go through my current assignments over time and still review occasionally. PS: sorry about the branch on upstream! changelog: none
…t-lang#14420) Commit efe3fe9 removed the ability for `single_match` and `single_match_else` to trigger if comments were present outside of the arms, as those comments would be lost while rewriting the `match` expression. This reinstates the lint, but prevents the suggestion from being applied automatically in the presence of comments by using the `MaybeIncorrect` applicability. Also, a note is added to the lint message to warn the user about the need to preserve the comments if acting upon the suggestion. changelog: [`single_match`, `single_match_else`]: reinstate lint when comments are inside the `match` but do not autofix the code Fix rust-lang#14418
TLDR ```diff - /// 01234 + /// 01234 12345 ``` Sometimes, in doc comments, there are 3 spaces + 1 instead of 4 spaces + 1. To make it coherent with the rest of the clippy codebase, I `fd -t f -X sed -E -i 's,///\s{4}(\S),/// \1,g'` and manually verified and fixed the relevant part of code that had bad indentation. ### Example ```rs /// fn a() { /// 01234 /// } ``` Becomes ```rs /// fn a() { /// 01234 /// } ``` changelog: none
) fixes rust-lang#13964 The lint `option_map_unwrap_or` used to have a similar issue in rust-lang#10579, so I borrowed its solution to fix this one. changelog: [`option_if_let_else`]: fix FP when value partially moved
changelog: [`question_mark`]: Now respects the [`msrv`] configuration
…less_late_init` (rust-lang#14169) fixes rust-lang#9895 changelog: [`needless_late_init`]: correct suggestion when assignments have enclosing parentheses
The applicability of `never_loop` is currently set to `Unspecified`, but if the loop block does not contain `break` or `continue`, it can be `MachineApplicable`. changelog: [`never_loop`]: the applicability is now `MachineApplicable` when the loop block contains neither `break` nor `continue`
r? @ghost changelog: none
) Closes rust-lang#14020 Closes rust-lang#14290 Closes rust-lang#14091 Add checks for unstable const traits. changelog: [`missing_const_for_fn`] fix FP on unstable const traits
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
@bors r+ p=1 rollup=never |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 01dc45c (parent) -> 5d85a71 (this PR) Test differencesShow 32888 test diffs
(and 16356 additional test diffs) Additionally, 16432 doctest diffs were found. These are ignored, as they are noisy. Job group index
|
Finished benchmarking commit (5d85a71): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -2.7%, secondary -3.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 2.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 774.81s -> 774.966s (0.02%) |
r? @Manishearth
Cargo.lock update is because of the
ui_test
dependency bump in Clippy.